@wacht/jsx 0.0.1-alpha.40 → 0.0.1-alpha.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- "use strict";var xd=Object.defineProperty;var vd=(t,r,o)=>r in t?xd(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var tt=(t,r,o)=>vd(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),Wr=require("react-dom"),Bs=require("@wacht/types"),nc=a.createContext(void 0);function bd({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[s,i]=a.useState(!0),[u,f]=a.useState(null),c=a.useRef(!1);a.useEffect(()=>{async function l(){if(c.current)return;c.current=!0,i(!0);const[p,g,x]=r.split("_");if(!x)throw new Error("Invalid public key");let m=atob(x),b=g==="test",$=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){$=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",$??"");const C=new URL(window.location.href);C.searchParams.delete("__dev_session__"),window.history.replaceState({},"",C.toString())}else $=localStorage.getItem("__dev_session__");let z={};const w=new URLSearchParams;b?w.append("__dev_session__",$??""):z={credentials:"include"};const y=await fetch(`${m}/deployment${b?"?":""}${w.toString()}`,z);if(!y.ok){i(!1);return}const k=await y.json();k.data.backend_host=m,n&&(k.data.ui_settings={...k.data.ui_settings,...n}),f(k.data),b&&y.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",y.headers.get("x-development-session")??""),i(!1)}l()},[r]);const h=a.useMemo(()=>({loading:s,deployment:u,adapter:o}),[s,u,o]);return e.jsx(nc.Provider,{value:h,children:t})}function ve(){const t=a.useContext(nc);if(t===void 0)throw new Error("useDeployment must be used within a DeploymentProvider");if(!t.loading&&!t.deployment)throw new Error("Deployment is not loaded");return t}function Fe(){const{deployment:t,loading:r}=ve();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,s)=>{const i=yd(t),u=new Headers(i.headers);s!=null&&s.headers&&new Headers(s.headers).forEach((l,p)=>{u.set(p,l)});const f=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&f.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(f,{...i,...s,headers:u});return t.mode==="staging"&&c.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",c.headers.get("x-development-session")??""),c},loading:r}}function yd(t){return t.mode==="staging"?{}:{credentials:"include"}}var Kr={exports:{}},ln={};/**
2
+ "use strict";var xd=Object.defineProperty;var vd=(t,r,o)=>r in t?xd(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var tt=(t,r,o)=>vd(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),Wr=require("react-dom"),Bs=require("@wacht/types"),nc=i.createContext(void 0);function bd({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[s,a]=i.useState(!0),[p,f]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function l(){if(c.current)return;c.current=!0,a(!0);const[u,g,v]=r.split("_");if(!v)throw new Error("Invalid public key");let x=atob(v),w=g==="test",$=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){$=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",$??"");const z=new URL(window.location.href);z.searchParams.delete("__dev_session__"),window.history.replaceState({},"",z.toString())}else $=localStorage.getItem("__dev_session__");let S={};const k=new URLSearchParams;w?k.append("__dev_session__",$??""):S={credentials:"include"};const P=await fetch(`${x}/deployment${w?"?":""}${k.toString()}`,S);if(!P.ok){a(!1);return}const E=await P.json();E.data.backend_host=x,n&&(E.data.ui_settings={...E.data.ui_settings,...n}),f(E.data),w&&P.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",P.headers.get("x-development-session")??""),a(!1)}l()},[r]);const h=i.useMemo(()=>({loading:s,deployment:p,adapter:o}),[s,p,o]);return e.jsx(nc.Provider,{value:h,children:t})}function ve(){const t=i.useContext(nc);if(t===void 0)throw new Error("useDeployment must be used within a DeploymentProvider");if(!t.loading&&!t.deployment)throw new Error("Deployment is not loaded");return t}function Be(){const{deployment:t,loading:r}=ve();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,s)=>{const a=yd(t),p=new Headers(a.headers);s!=null&&s.headers&&new Headers(s.headers).forEach((l,u)=>{p.set(u,l)});const f=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&f.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(f,{...a,...s,headers:p});return t.mode==="staging"&&c.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",c.headers.get("x-development-session")??""),c},loading:r}}function yd(t){return t.mode==="staging"?{}:{credentials:"include"}}var Kr={exports:{}},ln={};/**
3
3
  * @license React
4
4
  * use-sync-external-store-shim.production.js
5
5
  *
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var Us;function wd(){if(Us)return ln;Us=1;var t=a;function r(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,s=t.useEffect,i=t.useLayoutEffect,u=t.useDebugValue;function f(p,g){var x=g(),m=n({inst:{value:x,getSnapshot:g}}),b=m[0].inst,$=m[1];return i(function(){b.value=x,b.getSnapshot=g,c(b)&&$({inst:b})},[p,x,g]),s(function(){return c(b)&&$({inst:b}),p(function(){c(b)&&$({inst:b})})},[p]),u(x),x}function c(p){var g=p.getSnapshot;p=p.value;try{var x=g();return!o(p,x)}catch{return!0}}function h(p,g){return g()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:f;return ln.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,ln}var dn={};/**
10
+ */var Us;function wd(){if(Us)return ln;Us=1;var t=i;function r(u,g){return u===g&&(u!==0||1/u===1/g)||u!==u&&g!==g}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,s=t.useEffect,a=t.useLayoutEffect,p=t.useDebugValue;function f(u,g){var v=g(),x=n({inst:{value:v,getSnapshot:g}}),w=x[0].inst,$=x[1];return a(function(){w.value=v,w.getSnapshot=g,c(w)&&$({inst:w})},[u,v,g]),s(function(){return c(w)&&$({inst:w}),u(function(){c(w)&&$({inst:w})})},[u]),p(v),v}function c(u){var g=u.getSnapshot;u=u.value;try{var v=g();return!o(u,v)}catch{return!0}}function h(u,g){return g()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:f;return ln.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,ln}var dn={};/**
11
11
  * @license React
12
12
  * use-sync-external-store-shim.development.js
13
13
  *
@@ -15,12 +15,12 @@
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var Ws;function jd(){return Ws||(Ws=1,process.env.NODE_ENV!=="production"&&function(){function t(x,m){return x===m&&(x!==0||1/x===1/m)||x!==x&&m!==m}function r(x,m){l||s.startTransition===void 0||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var b=m();if(!p){var $=m();i(b,$)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),p=!0)}$=u({inst:{value:b,getSnapshot:m}});var z=$[0].inst,w=$[1];return c(function(){z.value=b,z.getSnapshot=m,o(z)&&w({inst:z})},[x,b,m]),f(function(){return o(z)&&w({inst:z}),x(function(){o(z)&&w({inst:z})})},[x]),h(b),b}function o(x){var m=x.getSnapshot;x=x.value;try{var b=m();return!i(x,b)}catch{return!0}}function n(x,m){return m()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=a,i=typeof Object.is=="function"?Object.is:t,u=s.useState,f=s.useEffect,c=s.useLayoutEffect,h=s.useDebugValue,l=!1,p=!1,g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;dn.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())}()),dn}var Vs;function _d(){return Vs||(Vs=1,process.env.NODE_ENV==="production"?Kr.exports=wd():Kr.exports=jd()),Kr.exports}var kd=_d();const sc=0,ic=1,ac=2,Gs=3;var Hs=Object.prototype.hasOwnProperty;function Kn(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&Kn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Hs.call(t,o)&&++n&&!Hs.call(r,o)||!(o in r)||!Kn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const jt=new WeakMap,Et=()=>{},qe=Et(),Qn=Object,Se=t=>t===qe,lt=t=>typeof t=="function",Pt=(t,r)=>({...t,...r}),cc=t=>lt(t.then),un={},Qr={},ys="undefined",Vr=typeof window!=ys,Xn=typeof document!=ys,Cd=Vr&&"Deno"in window,Sd=()=>Vr&&typeof window.requestAnimationFrame!=ys,lc=(t,r)=>{const o=jt.get(t);return[()=>!Se(r)&&t.get(r)||un,n=>{if(!Se(r)){const s=t.get(r);r in Qr||(Qr[r]=s),o[5](r,Pt(s,n),s||un)}},o[6],()=>!Se(r)&&r in Qr?Qr[r]:!Se(r)&&t.get(r)||un]};let Jn=!0;const zd=()=>Jn,[es,ts]=Vr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Et,Et],$d=()=>{const t=Xn&&document.visibilityState;return Se(t)||t!=="hidden"},Ed=t=>(Xn&&document.addEventListener("visibilitychange",t),es("focus",t),()=>{Xn&&document.removeEventListener("visibilitychange",t),ts("focus",t)}),Id=t=>{const r=()=>{Jn=!0,t()},o=()=>{Jn=!1};return es("online",r),es("offline",o),()=>{ts("online",r),ts("offline",o)}},Pd={isOnline:zd,isVisible:$d},Rd={initFocus:Ed,initReconnect:Id},qs=!a.useId,Fr=!Vr||Cd,Td=t=>Sd()?window.requestAnimationFrame(t):setTimeout(t,1),pn=Fr?a.useEffect:a.useLayoutEffect,hn=typeof navigator<"u"&&navigator.connection,Ys=!Fr&&hn&&(["slow-2g","2g"].includes(hn.effectiveType)||hn.saveData),Xr=new WeakMap,Md=t=>Qn.prototype.toString.call(t),fn=(t,r)=>t===`[object ${r}]`;let Od=0;const rs=t=>{const r=typeof t,o=Md(t),n=fn(o,"Date"),s=fn(o,"RegExp"),i=fn(o,"Object");let u,f;if(Qn(t)===t&&!n&&!s){if(u=Xr.get(t),u)return u;if(u=++Od+"~",Xr.set(t,u),Array.isArray(t)){for(u="@",f=0;f<t.length;f++)u+=rs(t[f])+",";Xr.set(t,u)}if(i){u="#";const c=Qn.keys(t).sort();for(;!Se(f=c.pop());)Se(t[f])||(u+=f+":"+rs(t[f])+",");Xr.set(t,u)}}else u=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return u},ws=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?rs(t):"",[t,r]};let Ad=0;const os=()=>++Ad;async function dc(...t){const[r,o,n,s]=t,i=Pt({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let u=i.populateCache;const f=i.rollbackOnError;let c=i.optimisticData;const h=g=>typeof f=="function"?f(g):f!==!1,l=i.throwOnError;if(lt(o)){const g=o,x=[],m=r.keys();for(const b of m)!/^\$(inf|sub)\$/.test(b)&&g(r.get(b)._k)&&x.push(b);return Promise.all(x.map(p))}return p(o);async function p(g){const[x]=ws(g);if(!x)return;const[m,b]=lc(r,x),[$,z,w,y]=jt.get(r),k=()=>{const R=$[x];return(lt(i.revalidate)?i.revalidate(m().data,g):i.revalidate!==!1)&&(delete w[x],delete y[x],R&&R[0])?R[0](ac).then(()=>m().data):m().data};if(t.length<3)return k();let C=n,_,v=!1;const P=os();z[x]=[P,0];const I=!Se(c),S=m(),T=S.data,E=S._c,j=Se(E)?T:E;if(I&&(c=lt(c)?c(j,T):c,b({data:c,_c:j})),lt(C))try{C=C(j)}catch(R){_=R,v=!0}if(C&&cc(C))if(C=await C.catch(R=>{_=R,v=!0}),P!==z[x][0]){if(v)throw _;return C}else v&&I&&h(_)&&(u=!0,b({data:j,_c:qe}));if(u&&!v)if(lt(u)){const R=u(C,j);b({data:R,error:qe,_c:qe})}else b({data:C,error:qe,_c:qe});if(z[x][1]=os(),Promise.resolve(k()).then(()=>{b({_c:qe})}),v){if(l)throw _;return}return C}}const Zs=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},Ld=(t,r)=>{if(!jt.has(t)){const o=Pt(Rd,r),n=Object.create(null),s=dc.bind(qe,t);let i=Et;const u=Object.create(null),f=(l,p)=>{const g=u[l]||[];return u[l]=g,g.push(p),()=>g.splice(g.indexOf(p),1)},c=(l,p,g)=>{t.set(l,p);const x=u[l];if(x)for(const m of x)m(p,g)},h=()=>{if(!jt.has(t)&&(jt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),s,c,f]),!Fr)){const l=o.initFocus(setTimeout.bind(qe,Zs.bind(qe,n,sc))),p=o.initReconnect(setTimeout.bind(qe,Zs.bind(qe,n,ic)));i=()=>{l&&l(),p&&p(),jt.delete(t)}}};return h(),[t,s,h,i]}return[t,jt.get(t)[4]]},Dd=(t,r,o,n,s)=>{const i=o.errorRetryCount,u=s.retryCount,f=~~((Math.random()+.5)*(1<<(u<8?u:8)))*o.errorRetryInterval;!Se(i)&&u>i||setTimeout(n,f,s)},Nd=Kn,[uc,Or]=Ld(new Map),Fd=Pt({onLoadingSlow:Et,onSuccess:Et,onError:Et,onErrorRetry:Dd,onDiscarded:Et,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ys?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ys?5e3:3e3,compare:Nd,isPaused:()=>!1,cache:uc,mutate:Or,fallback:{}},Pd),Bd=(t,r)=>{const o=Pt(t,r);if(r){const{use:n,fallback:s}=t,{use:i,fallback:u}=r;n&&i&&(o.use=n.concat(i)),s&&u&&(o.fallback=Pt(s,u))}return o},Ud=a.createContext({}),Wd="$inf$",pc=Vr&&window.__SWR_DEVTOOLS_USE__,Vd=pc?window.__SWR_DEVTOOLS_USE__:[],Gd=()=>{pc&&(window.__SWR_DEVTOOLS_REACT__=a)},Hd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],hc=()=>Pt(Fd,a.useContext(Ud)),qd=t=>(r,o,n)=>t(r,o&&((...i)=>{const[u]=ws(r),[,,,f]=jt.get(uc);if(u.startsWith(Wd))return o(...i);const c=f[u];return Se(c)?o(...i):(delete f[u],c)}),n),Yd=Vd.concat(qd),Zd=t=>function(...o){const n=hc(),[s,i,u]=Hd(o),f=Bd(n,u);let c=t;const{use:h}=f,l=(h||[]).concat(Yd);for(let p=l.length;p--;)c=l[p](c);return c(s,i||f.fetcher||null,f)},Kd=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const s=n.indexOf(o);s>=0&&(n[s]=n[n.length-1],n.pop())}};Gd();const gn=a.use||(t=>{switch(t.status){case"pending":throw t;case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t.status="pending",t.then(r=>{t.status="fulfilled",t.value=r},r=>{t.status="rejected",t.reason=r}),t}}),mn={dedupe:!0},Qd=(t,r,o)=>{const{cache:n,compare:s,suspense:i,fallbackData:u,revalidateOnMount:f,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:l,refreshWhenOffline:p,keepPreviousData:g}=o,[x,m,b,$]=jt.get(n),[z,w]=ws(t),y=a.useRef(!1),k=a.useRef(!1),C=a.useRef(z),_=a.useRef(r),v=a.useRef(o),P=()=>v.current,I=()=>P().isVisible()&&P().isOnline(),[S,T,E,j]=lc(n,z),R=a.useRef({}).current,M=Se(u)?Se(o.fallback)?qe:o.fallback[z]:u,F=(ue,U)=>{for(const pe in R){const K=pe;if(K==="data"){if(!s(ue[K],U[K])&&(!Se(ue[K])||!s(te,U[K])))return!1}else if(U[K]!==ue[K])return!1}return!0},A=a.useMemo(()=>{const ue=!z||!r?!1:Se(f)?P().isPaused()||i?!1:c!==!1:f,U=fe=>{const W=Pt(fe);return delete W._k,ue?{isValidating:!0,isLoading:!0,...W}:W},pe=S(),K=j(),H=U(pe),ne=pe===K?H:U(K);let me=H;return[()=>{const fe=U(S());return F(fe,me)?(me.data=fe.data,me.isLoading=fe.isLoading,me.isValidating=fe.isValidating,me.error=fe.error,me):(me=fe,fe)},()=>ne]},[n,z]),B=kd.useSyncExternalStore(a.useCallback(ue=>E(z,(U,pe)=>{F(pe,U)||ue()}),[n,z]),A[0],A[1]),O=!y.current,L=x[z]&&x[z].length>0,X=B.data,ee=Se(X)?M&&cc(M)?gn(M):M:X,V=B.error,q=a.useRef(ee),te=g?Se(X)?Se(q.current)?ee:q.current:X:ee,re=L&&!Se(V)?!1:O&&!Se(f)?f:P().isPaused()?!1:i?Se(ee)?!1:c:Se(ee)||c,le=!!(z&&r&&O&&re),oe=Se(B.isValidating)?le:B.isValidating,de=Se(B.isLoading)?le:B.isLoading,Z=a.useCallback(async ue=>{const U=_.current;if(!z||!U||k.current||P().isPaused())return!1;let pe,K,H=!0;const ne=ue||{},me=!b[z]||!ne.dedupe,fe=()=>qs?!k.current&&z===C.current&&y.current:z===C.current,W={isValidating:!1,isLoading:!1},N=()=>{T(W)},D=()=>{const ie=b[z];ie&&ie[1]===K&&delete b[z]},Y={isValidating:!0};Se(S().data)&&(Y.isLoading=!0);try{if(me&&(T(Y),o.loadingTimeout&&Se(S().data)&&setTimeout(()=>{H&&fe()&&P().onLoadingSlow(z,o)},o.loadingTimeout),b[z]=[U(w),os()]),[pe,K]=b[z],pe=await pe,me&&setTimeout(D,o.dedupingInterval),!b[z]||b[z][1]!==K)return me&&fe()&&P().onDiscarded(z),!1;W.error=qe;const ie=m[z];if(!Se(ie)&&(K<=ie[0]||K<=ie[1]||ie[1]===0))return N(),me&&fe()&&P().onDiscarded(z),!1;const J=S().data;W.data=s(J,pe)?J:pe,me&&fe()&&P().onSuccess(pe,z,o)}catch(ie){D();const J=P(),{shouldRetryOnError:_e}=J;J.isPaused()||(W.error=ie,me&&fe()&&(J.onError(ie,z,J),(_e===!0||lt(_e)&&_e(ie))&&(!P().revalidateOnFocus||!P().revalidateOnReconnect||I())&&J.onErrorRetry(ie,z,J,be=>{const ze=x[z];ze&&ze[0]&&ze[0](Gs,be)},{retryCount:(ne.retryCount||0)+1,dedupe:!0})))}return H=!1,N(),!0},[z,n]),se=a.useCallback((...ue)=>dc(n,C.current,...ue),[]);if(pn(()=>{_.current=r,v.current=o,Se(X)||(q.current=X)}),pn(()=>{if(!z)return;const ue=Z.bind(qe,mn);let U=0;P().revalidateOnFocus&&(U=Date.now()+P().focusThrottleInterval);const K=Kd(z,x,(H,ne={})=>{if(H==sc){const me=Date.now();P().revalidateOnFocus&&me>U&&I()&&(U=me+P().focusThrottleInterval,ue())}else if(H==ic)P().revalidateOnReconnect&&I()&&ue();else{if(H==ac)return Z();if(H==Gs)return Z(ne)}});return k.current=!1,C.current=z,y.current=!0,T({_k:w}),re&&(b[z]||(Se(ee)||Fr?ue():Td(ue))),()=>{k.current=!0,K()}},[z]),pn(()=>{let ue;function U(){const K=lt(h)?h(S().data):h;K&&ue!==-1&&(ue=setTimeout(pe,K))}function pe(){!S().error&&(l||P().isVisible())&&(p||P().isOnline())?Z(mn).then(U):U()}return U(),()=>{ue&&(clearTimeout(ue),ue=-1)}},[h,l,p,z]),a.useDebugValue(te),i&&Se(ee)&&z){if(!qs&&Fr)throw new Error("Fallback data is required when using Suspense in SSR.");_.current=r,v.current=o,k.current=!1;const ue=$[z];if(!Se(ue)){const U=se(ue);gn(U)}if(Se(V)){const U=Z(mn);Se(te)||(U.status="fulfilled",U.value=!0),gn(U)}else throw V}return{mutate:se,get data(){return R.data=!0,te},get error(){return R.error=!0,V},get isValidating(){return R.isValidating=!0,oe},get isLoading(){return R.isLoading=!0,de}}},Be=Zd(Qd);async function G(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}return{data:(await t.json()).data}}function fc(t){const{client:r}=Fe(),o=a.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await G(c)).data},[r,t]),{data:n,error:s,mutate:i}=Be(t?`wacht-agent-sessions:${t}`:null,o,{revalidateOnFocus:!1}),u=a.useCallback(async c=>{const h=new FormData;h.append("title",c.title),c.system_instructions&&h.append("system_instructions",c.system_instructions);const l=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:h}),p=await G(l);return await i(g=>g&&{...g,data:[p.data,...g.data]}),p.data},[r,t,i]),f=a.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await i(h=>h&&{...h,data:h.data.filter(l=>l.id!==c)})},[r,t,i]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!s,error:s,createSession:u,deleteSession:f,refetch:async()=>{await i()}}}const gc=a.createContext(void 0);function qo(){const t=a.useContext(gc);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Xd({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:s,onSessionCreated:i,onSessionDeleted:u,onError:f}){const[c,h]=a.useState(s?{id:s,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[l,p]=a.useState(!1),{sessions:g,loading:x,error:m,createSession:b,deleteSession:$,refetch:z}=fc(o);a.useEffect(()=>{if(s&&g.length>0){const _=g.find(v=>v.id===s);_&&h(_)}},[s,g]);const w=a.useCallback(_=>{h(_),p(!1)},[]),y=a.useCallback(async _=>{try{const v=_||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,P=await b({title:v});return h(P),i==null||i(P),P}catch(v){const P=v instanceof Error?v.message:"Failed to create session";throw f==null||f(P),v}},[b,i,f]),k=a.useCallback(async _=>{try{await $(_),(c==null?void 0:c.id)===_&&h(null),u==null||u(_)}catch(v){const P=v instanceof Error?v.message:"Failed to delete session";throw f==null||f(P),v}},[$,c,u,f]),C={agentName:r,token:o,platformAdapter:n,sessions:g,selectedSession:c,loadingSessions:x,sessionError:m,selectSession:w,createSession:y,deleteSession:k,refreshSessions:z,showHistory:l,setShowHistory:p,onSessionCreated:i,onSessionDeleted:u,onError:f};return e.jsx(gc.Provider,{value:C,children:t})}var mc=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(mc||{});function Jd(t,r){const o={username:eu(t,r),email:tu(t,r),phone:ru(t,r),email_otp:ou(t,r),magic_link:nu(t,r),oauth:su(t),generic:iu(t,r)};return function(s){return o[s]}}function eu(t,r){return async({username:o,password:n})=>{var f,c;const s=new FormData;s.append("strategy","plain_username"),s.append("username",o),s.append("password",n);const i=await t("/auth/signin",{method:"POST",body:s}),u=await G(i);return"data"in u&&((c=(f=u.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(u.data.signin_attempts.at(-1)||null),u}}function tu(t,r){return async({email:o,password:n})=>{var f,c;const s=new FormData;s.append("strategy","plain_email"),s.append("email",o),s.append("password",n);const i=await t("/auth/signin",{method:"POST",body:s}),u=await G(i);return"data"in u&&((c=(f=u.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(u.data.signin_attempts.at(-1)||null),u}}function ru(t,r){return async({phone:o})=>{var u,f;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const s=await t("/auth/signin",{method:"POST",body:n}),i=await G(s);return"data"in i&&((f=(u=i.data)==null?void 0:u.signin_attempts)!=null&&f.length)&&r(i.data.signin_attempts.at(-1)||null),i}}function ou(t,r){return async({email:o})=>{var u,f;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),i=await G(s);return"data"in i&&((f=(u=i.data)==null?void 0:u.signin_attempts)!=null&&f.length)&&r(i.data.signin_attempts.at(-1)||null),i}}function nu(t,r){return async({email:o})=>{var u,f;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),i=await G(s);return"data"in i&&((f=(u=i.data)==null?void 0:u.signin_attempts)!=null&&f.length)&&r(i.data.signin_attempts.at(-1)||null),i}}function su(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const s=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),i=await G(s);return"data"in i&&i.data.oauth_url&&(window.location.href=i.data.oauth_url),i}}function iu(t,r){return async({email:o,username:n,password:s,phone:i,strategy:u,token:f})=>{var p,g;const c=new FormData;u&&c.append("strategy",u),o&&c.append("email",o),n&&c.append("username",n),s&&c.append("password",s),i&&c.append("phone",i),f&&c.append("token",f);const h=await t("/auth/signin",{method:"POST",body:c}),l=await G(h);return"data"in l&&((g=(p=l.data)==null?void 0:p.signin_attempts)!=null&&g.length)&&r(l.data.signin_attempts.at(-1)||null),l}}function xc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Jd(t,n),completeVerification:async s=>{var c,h;const i=new FormData;i.append("verification_code",s);const u=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:i}),f=await G(u);if("data"in f&&((h=(c=f.data)==null?void 0:c.signin_attempts)!=null&&h.length)){const l=f.data.signin_attempts.at(-1);return n(l||null),f.data}else throw new Error("Verification failed")},prepareVerification:async s=>{var f;const i=new URL("/auth/prepare-verification",window.location.origin);i.searchParams.set("attempt_identifier",((f=o==null?void 0:o.id)==null?void 0:f.toString())||""),i.searchParams.set("strategy",s.strategy),i.searchParams.set("identifier_type","signin"),s.strategy==="phone_otp"&&s.lastDigits?i.searchParams.set("last_digits",s.lastDigits):(s.strategy==="email_otp"&&s.redirectUri||s.strategy==="magic_link"&&s.redirectUri)&&i.searchParams.set("redirect_uri",s.redirectUri);const u=await t(i.pathname+i.search,{method:"POST"});return G(u)},completeProfile:async s=>{var c;if(!o)throw new Error("No signin attempt found");const i=new FormData;for(const[h,l]of Object.entries(s))l&&i.append(h,l);const u=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:i}),f=await G(u);if("data"in f&&f.data){const h=(c=f.data.signin_attempts)==null?void 0:c.find(l=>l.id===o.id);return h&&n(h),f.data}else throw new Error("Profile completion failed")},identify:async s=>{const i=new FormData;i.append("identifier",s);const u=await t("/auth/identify",{method:"POST",body:i});return(await G(u)).data},initEnterpriseSso:async(s,i)=>{const u=new URLSearchParams({connection_id:s});i&&u.append("redirect_uri",i);const f=await t(`/auth/sso/login?${u.toString()}`,{method:"POST"});return(await G(f)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function Br(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:s,setSignInAttempt:i}=xc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:s,setSignInAttempt:i};const u=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:u,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:s,setSignInAttempt:i}}function au(t,r,o){return{create:async n=>{var f,c,h;const s=new FormData;for(const[l,p]of Object.entries(n))s.append(l,p);const i=await t("/auth/signup",{method:"POST",body:s}),u=await G(i);return"data"in u&&((c=(f=u.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(((h=u.data.signup_attempts)==null?void 0:h.at(-1))||null),u},prepareVerification:async n=>{var u;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((u=r==null?void 0:r.id)==null?void 0:u.toString())||""),s.searchParams.set("strategy",n.strategy),s.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?s.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&s.searchParams.set("redirect_uri",n.redirectUri);const i=await t(s.pathname+s.search,{method:"POST"});return G(i)},completeVerification:async n=>{var f,c;const s=new FormData;s.append("verification_code",n);const i=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),u=await G(i);return"data"in u&&((c=(f=u.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(u.data.signup_attempts.at(-1)||null),u},validateDeploymentInvitation:async n=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),i=await G(s);return"data"in i&&i.data?i.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(s){return{valid:!1,message:s.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function vc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:au(t,o,n)}}const Ge=()=>{const{adapter:t,deployment:r}=ve(),o=t.useNavigate(),n=(c,h)=>{o?o(c,h):window.location.href=c},s=c=>{if(c)return c;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function cu(t){const r=await t("/session",{method:"GET"});return(await G(r)).data}async function lu(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return G(o)}async function du(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return G(n)}async function uu(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return G(o)}async function pu(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return G(o)}const ns=new Map,Ar=new Map;function _t(){ns.clear(),Ar.clear()}async function hu(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return G(o)}function Ue(){const{client:t,loading:r}=Fe(),{deployment:o}=ve(),{navigate:n}=Ge(),{cache:s}=hc(),{data:i,error:u,mutate:f,isLoading:c}=Be(r?null:"/session",()=>cu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=a.useCallback(async()=>{await f(void 0,{revalidate:!0})},[f]),l=a.useCallback(async(p="default")=>{if(!i)throw new Error("no session");const g=ns.get(p);if(g&&g.expires>Date.now())return(g==null?void 0:g.token)||"";Ar.get(p)||Ar.set(p,hu(t,p));const x=await Ar.get(p);return Ar.delete(p),ns.set(p,x.data),x.data.token},[t,i==null?void 0:i.active_signin]);return r||!i||c?{loading:!0,error:u,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:h}:{loading:c,error:u,session:i,switchSignIn:async p=>{await lu(t,p),_t(),await Or("/me/organization-memberships",void 0,{revalidate:!1}),await Or("/me/workspace-memberships",void 0,{revalidate:!1}),await f(void 0,{revalidate:!0}),await Or("/me/organization-memberships"),await Or("/me/workspace-memberships")},signOut:async p=>{await du(t,p);const g=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],x=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(s instanceof Map){const m=Array.from(s.keys());for(const b of m){let $=!1;(g.includes(b)||typeof b=="string"&&x.some(z=>b.startsWith(z)))&&($=!0),$&&s.delete(b)}}_t(),await f(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(p&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!p&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async p=>{await uu(t,p),_t(),await f(void 0,{revalidate:!0})},switchWorkspace:async p=>{await pu(t,p),_t(),await f(void 0,{revalidate:!0})},getToken:l,refetch:h}}const Yo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=Ct(),{client:n}=Fe(),{refetch:s}=Ue(),i=a.useCallback(async B=>(await G(await n(`/organizations/${B.id}/roles`,{method:"GET"}))).data,[n]),u=a.useCallback(async B=>(await G(await n(`/organizations/${B.id}/members`,{method:"GET"}))).data,[n]),f=a.useCallback(async B=>(await G(await n(`/organizations/${B.id}/invitations`,{method:"GET"}))).data,[n]),c=a.useCallback(async B=>(await G(await n(`/organizations/${B.id}/domains`,{method:"GET"}))).data,[n]),h=a.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/members/${O.id}/remove`,{method:"POST"})},[n]),l=a.useCallback(async B=>{const O=new FormData;O.append("name",B.name),B.image&&O.append("image",B.image),B.description&&O.append("description",B.description);const L=await G(await n("/organizations",{method:"POST",body:O}));return _t(),await r(),await s(),L},[s,r,n]),p=a.useCallback(async(B,O)=>{const L=Object.entries(O).reduce((ee,[V,q])=>(q&&ee.append(V,q),ee),new FormData),X=await G(await n(`/organizations/${B.id}/update`,{method:"POST",body:L}));return await r(),X},[r,n]),g=a.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/roles/${O.id}/remove`,{method:"POST"})},[n]),x=a.useCallback(async(B,O)=>{const L=new FormData;return L.append("domain",O.fqdn),await G(await n(`/organizations/${B.id}/domains`,{method:"POST",body:L}))},[n]),m=a.useCallback(async(B,O)=>await G(await n(`/organizations/${B.id}/domains/${O.id}/verify`,{method:"POST"})),[n]),b=a.useCallback(async(B,O)=>await G(await n(`/organizations/${B.id}/domains/${O.id}/delete`,{method:"POST"})),[n]),$=a.useCallback(async B=>(await G(await n(`/organizations/${B.id}/enterprise-connections`,{method:"GET"}))).data,[n]),z=a.useCallback(async(B,O)=>{const L=new FormData;return L.append("protocol",O.protocol),O.domain_id&&L.append("domain_id",O.domain_id),O.idp_entity_id&&L.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&L.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&L.append("idp_certificate",O.idp_certificate),O.oidc_client_id&&L.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&L.append("oidc_client_secret",O.oidc_client_secret),O.oidc_issuer_url&&L.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_scopes&&L.append("oidc_scopes",O.oidc_scopes),O.jit_enabled!==void 0&&L.append("jit_enabled",String(O.jit_enabled)),O.attribute_mapping&&L.append("attribute_mapping",JSON.stringify(O.attribute_mapping)),(await G(await n(`/organizations/${B.id}/enterprise-connections`,{method:"POST",body:L}))).data},[n]),w=a.useCallback(async(B,O,L)=>{const X=new FormData;return L.domain_id&&X.append("domain_id",L.domain_id),L.idp_entity_id&&X.append("idp_entity_id",L.idp_entity_id),L.idp_sso_url&&X.append("idp_sso_url",L.idp_sso_url),L.idp_certificate&&X.append("idp_certificate",L.idp_certificate),L.oidc_client_id&&X.append("oidc_client_id",L.oidc_client_id),L.oidc_client_secret&&X.append("oidc_client_secret",L.oidc_client_secret),L.oidc_issuer_url&&X.append("oidc_issuer_url",L.oidc_issuer_url),L.oidc_scopes&&X.append("oidc_scopes",L.oidc_scopes),L.attribute_mapping&&X.append("attribute_mapping",JSON.stringify(L.attribute_mapping)),(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/update`,{method:"POST",body:X}))).data},[n]),y=a.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/enterprise-connections/${O}/delete`,{method:"POST"})},[n]),k=a.useCallback(async(B,O)=>{const L=new FormData;return L.append("protocol",O.protocol),O.idp_entity_id&&L.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&L.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&L.append("idp_certificate",O.idp_certificate),O.oidc_issuer_url&&L.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_client_id&&L.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&L.append("oidc_client_secret",O.oidc_client_secret),(await G(await n(`/organizations/${B.id}/enterprise-connections/test`,{method:"POST",body:L}))).data},[n]),C=a.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/test`,{method:"POST"}))).data,[n]),_=a.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/scim/token`,{method:"POST"}))).data,[n]),v=a.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/scim/token`,{method:"GET"}))).data,[n]),P=a.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/enterprise-connections/${O}/scim/token/revoke`,{method:"POST"})},[n]),I=a.useCallback(async(B,O)=>{const L=new FormData;return L.append("name",O.name),O.permissions&&O.permissions.forEach((ee,V)=>{L.append(`permissions[${V}]`,ee)}),await G(await n(`/organizations/${B.id}/roles`,{method:"POST",body:L}))},[n]),S=a.useCallback(async B=>(await G(await n(`/organizations/${B.id}/leave`,{method:"POST"}))).data,[n]),T=a.useCallback(async B=>{const O=await G(await n(`/organizations/${B.id}/delete`,{method:"POST"}));return _t(),await r(),await s(),O.data},[n,r,s]),E=a.useCallback(async(B,O,L)=>(await G(await n(`/organizations/${B.id}/members/${O.id}/roles/${L.id}/add`,{method:"POST"}))).data,[n]),j=a.useCallback(async(B,O,L)=>(await G(await n(`/organizations/${B.id}/members/${O.id}/roles/${L.id}/remove`,{method:"POST"}))).data,[n]),R=a.useCallback(async(B,O)=>{var ee,V;const L=new FormData;return L.append("email",O.email),L.append("role_id",O.organizationRole.id),(ee=O.workspace)!=null&&ee.id&&L.append("workspace_id",O.workspace.id),(V=O.workspaceRole)!=null&&V.id&&L.append("workspace_role_id",O.workspaceRole.id),(await G(await n(`/organizations/${B.id}/invitations`,{method:"POST",body:L}))).data},[n]),M=a.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/invitations/${O.id}/discard`,{method:"POST"}))).data,[n]),F=a.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/invitations/${O.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:a.useMemo(()=>t==null?void 0:t.map(B=>B.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:S,getOrganizationRoles:i,getOrganizationMembers:u,removeOrganizationMember:h,createOrganization:l,getOrganizationInvitations:f,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:m,removeOrganizationDomain:b,addRoleToOrganizationMember:E,removeRoleFromOrganizationMember:j,inviteOrganizationMember:R,discardOrganizationInvitation:M,resendOrganizationInvitation:F,updateOrganization:p,addRole:I,removeOrganizationRoles:g,deleteOrganization:T,getEnterpriseConnections:$,createEnterpriseConnection:z,updateEnterpriseConnection:w,deleteEnterpriseConnection:y,testEnterpriseConnectionConfig:k,testEnterpriseConnection:C,generateSCIMToken:_,getSCIMToken:v,revokeSCIMToken:P}},Ze=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:s,leaveOrganization:i,removeOrganizationMember:u,getOrganizationInvitations:f,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:l,verifyOrganizationDomain:p,addRoleToOrganizationMember:g,removeRoleFromOrganizationMember:x,inviteOrganizationMember:m,discardOrganizationInvitation:b,resendOrganizationInvitation:$,updateOrganization:z,removeOrganizationRoles:w,getEnterpriseConnections:y,createEnterpriseConnection:k,updateEnterpriseConnection:C,deleteEnterpriseConnection:_,testEnterpriseConnectionConfig:v,testEnterpriseConnection:P,generateSCIMToken:I,getSCIMToken:S,revokeSCIMToken:T}=Yo(),{session:E,error:j,loading:R}=Ue(),{organizationMemberships:M}=Ct(),F=a.useMemo(()=>(M==null?void 0:M.find(D=>{var Y;return D.id===((Y=E==null?void 0:E.active_signin)==null?void 0:Y.active_organization_membership_id)}))||null,[M,E]),A=a.useMemo(()=>(F==null?void 0:F.organization)||null,[F]),B=a.useCallback(async D=>A?await z(A,D):[],[A,z]),O=a.useCallback(async()=>A?await n(A):[],[A,n]),L=a.useCallback(async()=>A?await s(A):[],[A,s]),X=a.useCallback(async D=>A?await u(A,D):[],[A,u]),ee=a.useCallback(async D=>A?await w(A,D):void 0,[A,w]),V=a.useCallback(async()=>A?await c(A):[],[A,c]),q=a.useCallback(async D=>A?await l(A,D):void 0,[A,l]),te=a.useCallback(async D=>A?await p(A,D):void 0,[A,p]),re=a.useCallback(async D=>A?await h(A,D):void 0,[A,h]),le=a.useCallback(async(D,Y)=>A?await g(A,D,Y):void 0,[A,g]),oe=a.useCallback(async(D,Y)=>A?await x(A,D,Y):void 0,[A,x]),de=a.useCallback(async D=>A?await m(A,D):void 0,[A,m]),Z=a.useCallback(async D=>A?await b(A,D):void 0,[A,b]),se=a.useCallback(async D=>A?await $(A,D):void 0,[A,$]),xe=a.useCallback(async()=>{A&&await i(A)},[A,i]),ue=a.useCallback(async()=>A?await f(A):[],[A,f]),U=a.useCallback(async()=>A?await y(A):[],[A,y]),pe=a.useCallback(async D=>{if(A)return await k(A,D)},[A,k]),K=a.useCallback(async(D,Y)=>{if(A)return await C(A,D,Y)},[A,C]),H=a.useCallback(async D=>{A&&await _(A,D)},[A,_]),ne=a.useCallback(async D=>A?await v(A,D):null,[A,v]),me=a.useCallback(async D=>A?await P(A,D):null,[A,P]),fe=a.useCallback(async D=>{if(A)return await I(A,D)},[A,I]),W=a.useCallback(async D=>{if(A)return await S(A,D)},[A,S]),N=a.useCallback(async D=>{A&&await T(A,D)},[A,T]);return R||t?{activeOrganization:null,activeMembership:null,loading:!0,error:j||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:A,activeMembership:F,loading:!1,refetch:o,getRoles:L,updateOrganization:B,getMembers:O,getDomains:V,addDomain:q,verifyDomain:te,removeDomain:re,getInvitations:ue,removeMember:X,leave:xe,removeRole:ee,addMemberRole:le,removeMemberRole:oe,inviteMember:de,discardInvitation:Z,resendInvitation:se,getEnterpriseConnections:U,createEnterpriseConnection:pe,updateEnterpriseConnection:K,deleteEnterpriseConnection:H,testEnterpriseConnectionConfig:ne,testEnterpriseConnection:me,generateSCIMToken:fe,getSCIMToken:W,revokeSCIMToken:N,error:null}};async function fu(t){return(await G(await t("/me/organization-memberships"))).data}const Ct=()=>{const{client:t,loading:r}=Fe(),{data:o,isLoading:n,error:s,mutate:i}=Be(r?null:"/me/organization-memberships",()=>fu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),u=a.useCallback(async()=>{await i(void 0,{revalidate:!0})},[i]);return{organizationMemberships:o,loading:r||n,error:s,refetch:u}};async function gu(t){return(await G(await t("/me/workspace-memberships"))).data}async function mu(t,r,o){return(await G(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Zo=()=>{const{client:t,loading:r}=Fe(),{deployment:o}=ve(),{data:n,isLoading:s,error:i,mutate:u}=Be(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>gu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=a.useCallback(async()=>{await u(void 0,{revalidate:!0})},[u]);return{workspaceMemberships:n,loading:r||s,error:i,refetch:f}},St=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Zo(),{client:s}=Fe(),i=a.useMemo(()=>t==null?void 0:t.map(w=>({...w.workspace,organization:w.organization,eligibility_restriction:w.eligibility_restriction})),[t]),u=a.useCallback(async(w,y,k,C)=>{const _=new FormData;_.append("name",y),k&&_.append("image",k),C&&_.append("description",C),_.append("organization_id",w);const v=await G(await s("/workspaces",{method:"POST",body:_}));return _t(),await r(),v.data},[s,r]),f=a.useCallback(async(w,y)=>{const k=await mu(s,w,y);return await r(),k},[s,r]),c=a.useCallback(async(w,y)=>{const k=new FormData;y.name&&k.append("name",y.name),y.description&&k.append("description",y.description),y.image&&k.append("image",y.image),y.enforce_2fa!==void 0&&k.append("enforce_2fa",String(y.enforce_2fa)),y.enable_ip_restriction!==void 0&&k.append("enable_ip_restriction",String(y.enable_ip_restriction)),y.whitelisted_ips&&y.whitelisted_ips.forEach(_=>k.append("whitelisted_ips",_));const C=await G(await s(`/workspaces/${w.id}/update`,{method:"POST",body:k}));return await r(),C.data},[s,r]),h=a.useCallback(async w=>{const y=await G(await s(`/workspaces/${w.id}/delete`,{method:"POST"}));return _t(),await r(),y.data},[s,r]),l=a.useCallback(async w=>(await G(await s(`/workspaces/${w.id}/members`,{method:"GET"}))).data,[s]),p=a.useCallback(async w=>(await G(await s(`/workspaces/${w.id}/roles`,{method:"GET"}))).data,[s]),g=a.useCallback(async(w,y,k)=>(await G(await s(`/workspaces/${w.id}/roles`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y,permissions:k})}))).data,[s]),x=a.useCallback(async(w,y)=>(await G(await s(`/workspaces/${w.id}/roles/${y.id}/delete`,{method:"POST"}))).data,[s]),m=a.useCallback(async(w,y,k)=>(await G(await s(`/workspaces/${w.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:y,role_id:k})}))).data,[s]),b=a.useCallback(async(w,y)=>{const k=await G(await s(`/workspaces/${w.id}/members/${y}/remove`,{method:"POST"}));return await r(),k.data},[s,r]),$=a.useCallback(async(w,y,k)=>(await G(await s(`/workspaces/${w.id}/members/${y}/roles/${k}/add`,{method:"POST"}))).data,[s]),z=a.useCallback(async(w,y,k)=>(await G(await s(`/workspaces/${w.id}/members/${y}/roles/${k}/remove`,{method:"POST"}))).data,[s]);return{workspaces:i||[],loading:o,error:n,refetch:r,leaveWorkspace:f,createWorkspace:u,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:l,getWorkspaceRoles:p,createWorkspaceRole:g,deleteWorkspaceRole:x,inviteWorkspaceMember:m,removeWorkspaceMember:b,addWorkspaceMemberRole:$,removeWorkspaceMemberRole:z}},Rt=()=>{const{refetch:t,loading:r,error:o,leaveWorkspace:n,updateWorkspace:s,deleteWorkspace:i,getWorkspaceMembers:u,getWorkspaceRoles:f,createWorkspaceRole:c,deleteWorkspaceRole:h,inviteWorkspaceMember:l,removeWorkspaceMember:p,addWorkspaceMemberRole:g,removeWorkspaceMemberRole:x}=St(),{workspaceMemberships:m}=Zo(),{session:b,loading:$,error:z}=Ue(),w=a.useMemo(()=>(m==null?void 0:m.find(A=>{var B;return A.id===((B=b==null?void 0:b.active_signin)==null?void 0:B.active_workspace_membership_id)}))||null,[m,b]),y=a.useMemo(()=>(w==null?void 0:w.workspace)||null,[w]),k=a.useCallback(async()=>{var A;if(!(!y||!((A=b==null?void 0:b.active_signin)!=null&&A.user_id)))return await n(y.id,b.active_signin.user_id)},[y,n,b]),C=a.useCallback(async A=>{if(y)return await s(y,A)},[y,s]),_=a.useCallback(async()=>{if(y)return await i(y)},[y,i]),v=a.useCallback(async()=>y?await u(y):[],[y,u]),P=a.useCallback(async()=>y?await f(y):[],[y,f]),I=a.useCallback(async(A,B)=>{if(y)return await c(y,A,B)},[y,c]),S=a.useCallback(async A=>{if(y)return await h(y,A)},[y,h]),T=a.useCallback(async(A,B)=>{if(y)return await l(y,A,B)},[y,l]),E=a.useCallback(async A=>{if(y)return await p(y,A)},[y,p]),j=a.useCallback(async(A,B)=>{if(y)return await g(y,A,B)},[y,g]),R=a.useCallback(async(A,B)=>{if(y)return await x(y,A,B)},[y,x]),M=r||$,F=o||z;return M?{activeWorkspace:null,activeMembership:null,loading:!0,error:F,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null}:{activeWorkspace:y,activeMembership:w,loading:!1,error:F,refetch:t,leave:k,updateWorkspace:C,deleteWorkspace:_,getMembers:v,getRoles:P,createRole:I,deleteRole:S,inviteMember:T,removeMember:E,addMemberRole:j,removeMemberRole:R}},xu=async t=>(await G(await t("/me"))).data,vu=async t=>(await G(await t("/me/signins"))).data;function sr(){const{client:t,loading:r}=Fe(),{data:o,error:n,isLoading:s,mutate:i}=Be(r?null:"/user",()=>xu(t)),u=async R=>{const M=new FormData;for(const[A,B]of Object.entries(R))B!=null&&B!==""&&M.append(A,String(B));const F=await G(await t("/me",{method:"POST",body:M}));return i(),F},f=async()=>await G(await t("/me/email-addresses",{method:"GET"})),c=async R=>await G(await t(`/me/email-addresses/${R}`,{method:"GET"})),h=async R=>{const M=new FormData;return M.append("email",R),await G(await t("/me/email-addresses",{method:"POST",body:M}))},l=async R=>await G(await t(`/me/email-addresses/${R}/delete`,{method:"POST"})),p=async R=>await G(await t(`/me/email-addresses/${R}/prepare-verification`,{method:"POST"})),g=async(R,M)=>await G(await t(`/me/email-addresses/${R}/attempt-verification?code=${M}`,{method:"POST"})),x=async(R,M)=>{const F=new FormData;return F.append("phone_number",R),F.append("country_code",M),await G(await t("/me/phone-numbers",{method:"POST",body:F}))},m=async R=>await G(await t(`/me/phone-numbers/${R}/delete`,{method:"POST"})),b=async R=>await G(await t(`/me/phone-numbers/${R}/prepare-verification`,{method:"POST"})),$=async(R,M)=>{const F=new FormData;return F.append("code",M),await G(await t(`/me/phone-numbers/${R}/attempt-verification`,{method:"POST",body:F}))},z=async R=>{const M=await G(await t(`/me/phone-numbers/${R}/make-primary`,{method:"POST"}));return i(),M},w=async R=>await G(await t(`/me/email-addresses/${R}/make-primary`,{method:"POST"})),y=async()=>(await G(await t("/me/authenticator",{method:"POST"}))).data,k=async(R,M)=>{const F=new FormData;return F.append("authenticator_id",R),M.forEach(B=>{F.append("codes",B)}),await G(await t("/me/authenticator/attempt-verification",{method:"POST",body:F}))},C=async R=>await G(await t(`/me/authenticator/${R}/delete`,{method:"POST"})),_=async()=>(await G(await t("/me/backup-codes",{method:"POST"}))).data,v=async R=>{const M=new FormData;return M.append("file",R),await G(await t("/me/profile-picture",{method:"POST",body:M}))},P=async()=>(await G(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,I=async(R,M)=>{const F=new FormData;return F.append("current_password",R),F.append("new_password",M),await G(await t("/me/update-password",{method:"POST",body:F}))},S=async R=>{const M=new FormData;M.append("current_password",R);const F=await G(await t("/me/remove-password",{method:"POST",body:M}));return i(),F},T=async R=>{const M=new FormData;return M.append("password",R),await G(await t("/me/account/delete",{method:"POST",body:M}))},E=async R=>await G(await t(`/me/social-connections/${R}/disconnect`,{method:"POST"})),j=async({provider:R,redirectUri:M})=>{var B;const F=new URLSearchParams({provider:R});M&&F.append("redirect_uri",M);const A=await G(await t(`/me/init-sso-connection?${F.toString()}`,{method:"POST"}));return"data"in A&&((B=A.data)!=null&&B.oauth_url)&&window.open(A.data.oauth_url,"_blank"),A};return{user:{...o,refetch:i},loading:r||s,error:n||null,updateProfile:u,getEmailAddresses:f,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:l,prepareEmailVerification:p,attemptEmailVerification:g,makeEmailPrimary:w,createPhoneNumber:x,deletePhoneNumber:m,preparePhoneVerification:b,attemptPhoneVerification:$,makePhonePrimary:z,setupAuthenticator:y,verifyAuthenticator:k,deleteAuthenticator:C,generateBackupCodes:_,regenerateBackupCodes:P,updateProfilePicture:v,disconnectSocialConnection:E,connectSocialAccount:j,updatePassword:I,removePassword:S,deleteAccount:T}}function bc(){const{client:t,loading:r}=Fe(),{data:o,error:n,isLoading:s,mutate:i}=Be(r?null:"/me/signins",()=>vu(t));return{signins:o,error:n||null,removeSignin:async f=>await G(await t(`/me/signins/${f}/signout`,{method:"POST"})),refetch:i,loading:s||r}}function bu(){const{session:t,loading:r}=Ue(),{loading:o,organizationMemberships:n}=Ct(),{loading:s,workspaceMemberships:i}=Zo();if(r||o||s)return{loading:!0,orgMembership:null,workspaceMembership:null};const u=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_organization_membership_id)}),[t]),f=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:i==null?void 0:i.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:u,workspaceMembership:f}}function yc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(!1),s=async i=>{n(!0);try{const u=new FormData;for(const[h,l]of Object.entries(i))l&&u.append(h,l);const f=await t("/waitlist/join",{method:"POST",body:u});return await G(f)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:s}}function wc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(!1),[s,i]=a.useState(null),[u,f]=a.useState(null),[c,h]=a.useState(null),[l,p]=a.useState(!1),[g,x]=a.useState(null);a.useEffect(()=>{if(l||r)return;const b=new URLSearchParams(window.location.search),$=b.get("code"),z=b.get("state"),w=b.get("error"),y=b.get("error_description");if(!$&&!w){p(!0);const k=new Error("No OAuth callback data found.");i(k);return}if(p(!0),n(!0),w){const k=y||w,C=new Error(`OAuth Error: ${k}`);i(C),n(!1);return}if($&&z)m($,z);else{const k=new Error("Missing required OAuth parameters");i(k),n(!1)}},[l,r]);const m=async(b,$)=>{try{let z,w;try{const C=$.split(".");if(C.length!==2)throw new Error("Invalid OAuth state format - missing signature");const _=C[0].replace(/-/g,"+").replace(/_/g,"/"),v=_.length%4?"=".repeat(4-_.length%4):"",I=atob(_+v).split("|")[0];if(I==="sign_in")z="/auth/oauth2/callback",w="GET";else if(I==="connect_social")z="/me/sso-connection-callback",w="POST";else throw new Error(`Unknown OAuth action: ${I}`)}catch(C){const _=C instanceof Error?C:new Error("Failed to parse OAuth state");i(new Error(`Invalid OAuth callback: ${_.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const y=await t(`${z}?code=${encodeURIComponent(b)}&state=${encodeURIComponent($)}`,{method:w}),k=await G(y);if("data"in k){const C=k.data.session,_=k.data.redirect_uri||null;if(f(C),h(_),C.signin_attempts&&C.signin_attempts.length>0){const v=C.signin_attempts.at(-1);v&&x(v)}}else{const C=new Error("SSO callback failed");i(C)}}catch(z){const w=z instanceof Error?z:new Error("Unknown error occurred");i(w)}finally{n(!1)}};return{loading:o,error:s,session:u,redirectUri:c,processed:l,signinAttempt:g}}function jc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(!1),[s,i]=a.useState(null);return{loading:r||o,verifyMagicLink:async f=>{if(!f.token||!f.attempt)throw new Error("Invalid magic link parameters");n(!0),i(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",f.token),c.searchParams.set("attempt",f.attempt),f.redirectUri&&c.searchParams.set("redirect_uri",f.redirectUri);const h=await t(c.pathname+c.search,{method:"GET"}),l=await G(h);return n(!1),i(!0),l}catch(c){throw n(!1),i(!1),c}},success:s}}function _c(){const[t,r]=a.useState({});return a.useEffect(()=>{const o=new URLSearchParams(window.location.search);r({token:o.get("token")||void 0,attempt:o.get("attempt")||void 0,redirectUri:o.get("redirect_uri")||void 0})},[]),t}function kc(){const{client:t,loading:r}=Fe();return{loading:r,forgotPassword:async i=>{const u=new FormData;u.append("email",i);const f=await t("/auth/forgot-password",{method:"POST",body:u});return await G(f)},verifyOtp:async(i,u)=>{const f=new FormData;f.append("email",i),f.append("otp",u);const c=await t("/auth/forgot-password",{method:"POST",body:f});return await G(c)},resetPassword:async(i,u)=>{const f=new FormData;f.append("token",i),f.append("password",u);const c=await t("/auth/reset-password",{method:"POST",body:f});return await G(c)}}}function Cc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:s,onError:i,reconnectDelay:u=1e3,maxReconnectAttempts:f=5}={}){const{session:c,loading:h}=Ue(),{deployment:l,loading:p}=ve(),[g,x]=a.useState(!1),[m,b]=a.useState(null),$=a.useRef(null),z=a.useRef(null),w=a.useRef(0),y=a.useRef(null),k=a.useRef(s),C=a.useRef(i),_=a.useRef(r),v=a.useRef(o),P=a.useRef(n),I=a.useRef(u),S=a.useRef(f);k.current=s,C.current=i,_.current=r,v.current=o,P.current=n,I.current=u,S.current=f;const T=a.useCallback(()=>{z.current&&(clearTimeout(z.current),z.current=null),y.current&&(clearInterval(y.current),y.current=null),$.current&&($.current.close(),$.current=null)},[]),E=a.useCallback(async()=>{var B;if(!t||h||p||!c||!l)return;T();const M=new URL(l.backend_host),F=M.protocol==="https:"?"wss:":"ws:",A=new URL("/realtime/notifications",`${F}//${M.host}`);if(l.mode==="staging"){const O=localStorage.getItem("__dev_session__");O&&A.searchParams.set("__dev_session__",O)}_.current&&_.current.length>0&&_.current.forEach(O=>A.searchParams.append("channels",O)),v.current&&v.current.length>0&&v.current.forEach(O=>A.searchParams.append("organization_ids",O.toString())),P.current&&P.current.length>0&&P.current.forEach(O=>A.searchParams.append("workspace_ids",O.toString()));try{const O=new WebSocket(A.toString());$.current=O,O.onopen=()=>{x(!0),b(null),w.current=0,y.current=setInterval(()=>{O.readyState===WebSocket.OPEN&&O.send("ping")},3e4)},O.onmessage=L=>{var X,ee;try{const V=JSON.parse(L.data);if(V.type==="notification"&&V.data)(X=k.current)==null||X.call(k,V.data);else if(V.type==="error"){const q=V.error||"Unknown error occurred";b(q),(ee=C.current)==null||ee.call(C,q)}else V.type}catch{}},O.onerror=()=>{var L;b("Connection error occurred"),(L=C.current)==null||L.call(C,"Connection error occurred")},O.onclose=L=>{var X;if(x(!1),y.current&&(clearInterval(y.current),y.current=null),t&&L.code!==1e3&&w.current<S.current){w.current++;const ee=I.current*Math.pow(2,w.current-1);z.current=setTimeout(()=>{E()},ee)}else w.current>=S.current&&(b("Max reconnection attempts reached"),(X=C.current)==null||X.call(C,"Max reconnection attempts reached"))}}catch{b("Failed to connect"),(B=C.current)==null||B.call(C,"Failed to connect")}},[t,h,p,c,l,T]);a.useEffect(()=>(E(),()=>{T()}),[E,T]),a.useEffect(()=>{$.current&&$.current.readyState===WebSocket.OPEN&&E()},[r,o,n,E]);const j=a.useCallback(()=>{T(),x(!1)},[T]),R=a.useCallback(()=>{w.current=0,E()},[E]);return{isConnected:g,connectionError:m,disconnect:j,reconnect:R}}async function yu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(u=>o.append("channels",u)),r.organization_ids&&r.organization_ids.forEach(u=>o.append("organization_ids",u.toString())),r.workspace_ids&&r.workspace_ids.forEach(u=>o.append("workspace_ids",u.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,s=await t(n,{method:"GET"});return(await G(s)).data}async function wu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}async function ju(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return G(o)}async function _u(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return G(r)}async function ku(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return G(o)}function Sc(t){const{client:r,loading:o}=Fe(),{data:n,error:s,mutate:i,isLoading:u}=Be(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>yu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});Cc({enabled:!o&&!!n,onNotification:a.useCallback(p=>{i(async g=>!g||g.notifications.some(m=>m.id===p.id.toString())?g:{...g,notifications:[{id:p.id.toString(),user_id:p.user_id.toString(),deployment_id:p.deployment_id.toString(),title:p.title,body:p.body,severity:p.severity,action_url:p.action_url,action_label:p.action_label,is_read:!1,is_archived:!1,created_at:p.created_at,updated_at:p.created_at},...g.notifications],unread_count:g.unread_count+1,total:g.total+1},!1)},[i]),onError:a.useCallback(()=>{},[])});const f=a.useCallback(async p=>{o||(await i(async g=>g&&{...g,notifications:g.notifications.map(x=>x.id===p?{...x,is_read:!0}:x),unread_count:Math.max(0,g.unread_count-1)},!1),await ju(r,p),await i())},[r,o,i]),c=a.useCallback(async()=>{o||(await i(async p=>p&&{...p,notifications:p.notifications.map(g=>({...g,is_read:!0})),unread_count:0},!1),await _u(r),await i())},[r,i]),h=a.useCallback(async p=>{o||(await i(async g=>{if(!g)return g;const x=g.notifications.find(m=>m.id===p);return{...g,notifications:g.notifications.filter(m=>m.id!==p),unread_count:x&&!x.is_read?Math.max(0,g.unread_count-1):g.unread_count,total:Math.max(0,g.total-1)}},!1),await ku(r,p),await i())},[r,o,i]),l=a.useCallback(async()=>{await i()},[i]);return!n||o||u?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:s,refetch:l}:{loading:!1,error:s,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:f,markAllAsRead:c,deleteNotification:h,refetch:l}}async function Cu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}function Su(){const{client:t,loading:r}=Fe(),{data:o,error:n,mutate:s}=Be(r?null:"wacht-notifications:channel-counts",()=>Cu(t),{refreshInterval:3e4,revalidateOnFocus:!0}),i=async()=>{await s()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:i}:{loading:!1,counts:o,error:n,refetch:i}}const Yt=class Yt{constructor(){tt(this,"ws",null);tt(this,"messageHandlers",new Set);tt(this,"connectionStateHandlers",new Set);tt(this,"reconnectTimer",null);tt(this,"reconnectAttempts",0);tt(this,"url",null);tt(this,"isIntentionalDisconnect",!1);tt(this,"sessionMessages",{});tt(this,"currentSessionKey",null)}static getInstance(){return Yt.instance||(Yt.instance=new Yt),Yt.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};tt(Yt,"instance");let ss=Yt;const Xe=ss.getInstance(),wt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Le={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Ot={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Ks(t){switch(t){case Ot.IDLE:return Le.IDLE;case Ot.STARTING:return Le.STARTING;case Ot.RUNNING:return Le.RUNNING;case Ot.WAITING_FOR_INPUT:return Le.WAITING_FOR_INPUT;case Ot.COMPLETED:return Le.COMPLETED;case Ot.FAILED:case Ot.CANCELLED:return Le.FAILED;default:return Le.IDLE}}function Qs(t){return t===Le.STARTING||t===Le.RUNNING||t===Le.WAITING_FOR_INPUT}function zc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:s=!0}){const{deployment:i}=ve(),{client:u}=Fe(),[f,c]=a.useState([]),[h,l]=a.useState(null),[p,g]=a.useState(null),[x,m]=a.useState(!1),[b,$]=a.useState(!1),[z,w]=a.useState(Le.IDLE),[y,k]=a.useState({status:wt.DISCONNECTED}),[C,_]=a.useState(!0),[v,P]=a.useState(!1),I=a.useRef(null),S=a.useRef(null),T=a.useCallback(V=>{var q,te;switch(V.message_type){case"session_connected":if(m(!0),k({status:wt.CONNECTED}),(q=V.data)!=null&&q.execution_status){const le=V.data.execution_status,oe=Ks(le);w(oe),$(Qs(oe))}break;case"conversation_message":E(V.data);break;case"user_input_request":j(V.data);break;case"platform_event":R(V.data);break;case"platform_function":M(V.data);break;case"execution_complete":$(!1),w(Le.IDLE),S.current=null;break;case"execution_error":$(!1),w(Le.FAILED),S.current=null;break;case"execution_cancelled":$(!1),w(Le.IDLE),S.current=null;break;case"execution_status":const re=(te=V.data)==null?void 0:te.status;if(re){const le=Ks(re);w(le),$(Qs(le))}break}},[h]),E=a.useCallback(V=>{var oe,de,Z,se,xe,ue,U,pe;const{id:q,message_type:te,content:re}=V,le=K=>f.some(H=>H.id===K);if(te==="system_decision"||te==="action_execution_result"||te==="assistant_task_breakdown"||te==="assistant_validation"||te==="assistant_action_planning"||te==="context_results"){l(null),g(null);let K="";if(te==="system_decision"){const H=re==null?void 0:re.step,ne=re==null?void 0:re.reasoning;if(H==="gathercontext")ne&&ne.length>0?K=ne.length>60?`${ne.substring(0,60)}...`:ne:K="Gathering context...";else if(H==="executeaction")K="Executing action";else if(H==="deliverresponse")K="Preparing response";else if(H==="taskplanning")K="Planning approach";else if(H==="validateprogress")K="Validating progress";else if(H==="acknowledge")K="Processing request";else if(H==="finishplanning")K="Finalizing plan";else if(H==="executetasks")K="Executing tasks";else if(H==="requestuserinput")K="Waiting for input";else if(H==="complete")K="Completed";else if(H==="examinetool")K="Examining tool";else if(H==="examineworkflow")K="Examining workflow";else{const me=(re==null?void 0:re.confidence)||.5;me>.8?K="Analyzing":me>.6?K="Thinking":K="Reasoning"}}else if(te==="action_execution_result")((oe=re.task_execution)==null?void 0:oe.status)==="completed"?K="Task execution completed":(de=re.task_execution)!=null&&de.approach?K=re.task_execution.approach:K="Executing task";else if(te==="assistant_task_breakdown")(Z=re.task_breakdown)!=null&&Z.total_tasks?K=`Identified ${re.task_breakdown.total_tasks} tasks`:K="Planning tasks";else if(te==="assistant_validation")K="Validated results";else if(te==="assistant_action_planning")(se=re.task_execution)!=null&&se.total_tasks?K=`Planned ${re.task_execution.total_tasks} tasks`:(ue=(xe=re.task_execution)==null?void 0:xe.tasks)!=null&&ue.length?K=`Planned ${re.task_execution.tasks.length} tasks`:K="Planning actions";else if(te==="context_results"){const H=re.query,ne=re.result_count||0;H&&H!=="General context gathering"?K=`${H}: Found ${ne} results`:K=`Found ${ne} results`}K&&!le(q)&&c(H=>[...H,{id:q,role:"system",content:K,timestamp:new Date,metadata:{type:"log",messageType:te}}]);return}if(te==="user_message")le(q)||(l(null),g(null),c(K=>[...K,{id:q,role:"user",content:re.message,images:re.images,timestamp:new Date}]));else if(te==="agent_response")le(q)||(l(null),g(null),$(!1),w(Le.IDLE),S.current=null,c(K=>[...K,{id:q,role:"assistant",content:re.response,timestamp:new Date,isStreaming:!1}]));else if(te==="assistant_acknowledgment")le(q)||(l(null),g(null),c(K=>[...K,{id:q,role:"assistant",content:re.acknowledgment_message,timestamp:new Date}]));else if(te==="assistant_ideation"||te==="assistant_action_planning"||te==="action_execution_result"||te==="assistant_validation"||te==="assistant_context_gathering"||te==="assistant_task_breakdown"){let K="";if(re.reasoning_summary)K=re.reasoning_summary;else if((U=re.task_execution)!=null&&U.approach)K=re.task_execution.approach;else if(re.strategic_synthesis)K=re.strategic_synthesis;else if((pe=re.task_breakdown)!=null&&pe.total_tasks)K=`Breaking down into ${re.task_breakdown.total_tasks} tasks...`;else if(re.acknowledgment_message)K=re.acknowledgment_message;else return;c(H=>[...H,{id:q,role:"assistant",content:K,timestamp:new Date}])}else if(te==="user_input_request"){const K={question:re.question,context:re.context,input_type:re.input_type,options:re.options||re.suggestions,default_value:re.default_value,placeholder:re.placeholder};w("waiting_for_input"),c(H=>[...H,{id:q,role:"system",content:K.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:K}}])}},[]),j=a.useCallback(async V=>{w("waiting_for_input");const q=`input-request-${Date.now()}`;c(te=>[...te,{id:q,role:"system",content:V.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:V}}])},[]),R=a.useCallback(V=>{const{event_label:q,event_data:te}=V;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(q,te)},[n]),M=a.useCallback(async V=>{const{function_name:q,function_data:te}=V,{parameters:re,execution_id:le}=te;if(!(n!=null&&n.onPlatformFunction)){Xe.send({message_type:{platform_function_result:[le,{error:"No platform function handler registered"}]},data:{}});return}try{const oe=await n.onPlatformFunction(q,re,le),de={message_type:{platform_function_result:[le,oe]},data:{}};Xe.send(de)}catch(oe){Xe.send({message_type:{platform_function_result:[le,{error:oe instanceof Error?oe.message:"Function execution failed",stack:oe instanceof Error?oe.stack:void 0}]},data:{}})}},[n]);a.useEffect(()=>{if(!i)return;const q=`wss://${i==null?void 0:i.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;k({status:wt.CONNECTING}),Xe.connect(q)},[i,o]),a.useEffect(()=>Xe.onConnectionStateChange(q=>{k({status:q.isConnected?wt.CONNECTED:q.error?wt.ERROR:wt.DISCONNECTED}),m(q.isConnected)}),[]),a.useEffect(()=>Xe.onMessage(T),[T]),a.useEffect(()=>{x&&t&&r&&s&&Xe.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,s]);const F=a.useCallback(async()=>(x&&t&&r&&Xe.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),A=a.useCallback((V,q)=>{x&&(l(V),g(q||null),$(!0),w(Le.STARTING),Xe.send({message_type:{message_input:V},data:q?{images:q}:{}}))},[x]),B=a.useCallback(()=>{c([]),S.current=null},[]),O=a.useCallback(V=>{!x||z!==Le.WAITING_FOR_INPUT||(Xe.send({message_type:{user_input_response:V},data:{}}),w(Le.RUNNING))},[x,z]),L=a.useCallback(async V=>{var q;if(!(!o||!t))try{const te=new URLSearchParams({token:o,limit:"50"});V&&(te.append("before_id",V),P(!0));const le=await(await u(`/api/agent/contexts/${t}/messages?${te}`,{method:"GET"})).json();if(le.status===200&&le.data){const oe=le.data;if(Array.isArray(oe.data)){const de=oe.data.filter(Z=>{var ue;let se=Z.content;if(typeof Z.content=="string")try{se=JSON.parse(Z.content)}catch{se={message:Z.content}}const xe=((ue=Z.metadata)==null?void 0:ue.message_type)||(se==null?void 0:se.message_type);return xe==="user_message"||xe==="agent_response"||xe==="assistant_acknowledgment"||xe==="user_input_request"||xe==="system_decision"||xe==="action_execution_result"||xe==="assistant_task_breakdown"||xe==="assistant_validation"||xe==="assistant_action_planning"||xe==="context_results"}).map(Z=>{var K,H,ne,me,fe,W,N;let se="",xe,ue,U=Z.content;if(typeof Z.content=="string")try{U=JSON.parse(Z.content)}catch{U=Z.content}const pe=((K=Z.metadata)==null?void 0:K.message_type)||(U==null?void 0:U.message_type);if(pe==="user_message"?(se=(U==null?void 0:U.message)||"",xe=(U==null?void 0:U.images)||void 0):pe==="agent_response"?se=(U==null?void 0:U.response)||"":pe==="assistant_acknowledgment"?se=(U==null?void 0:U.acknowledgment_message)||"":pe==="user_input_request"&&(se=(U==null?void 0:U.question)||"",ue={type:"user_input_request",userInputRequest:{question:(U==null?void 0:U.question)||"",context:(U==null?void 0:U.context)||"",input_type:(U==null?void 0:U.input_type)||"text",options:(U==null?void 0:U.options)||(U==null?void 0:U.suggestions)||[],default_value:(U==null?void 0:U.default_value)||"",placeholder:(U==null?void 0:U.placeholder)||""}}),pe==="system_decision"||pe==="action_execution_result"||pe==="assistant_task_breakdown"||pe==="assistant_validation"||pe==="assistant_action_planning"||pe==="context_results"){let D="";if(pe==="system_decision"){const Y=U==null?void 0:U.step,ie=U==null?void 0:U.reasoning;if(Y==="gathercontext")ie&&ie.length>0?D=ie.length>60?`${ie.substring(0,60)}...`:ie:D="Gathering context...";else if(Y==="executeaction")D="Executing action";else if(Y==="deliverresponse")D="Preparing response";else if(Y==="taskplanning")D="Planning approach";else if(Y==="validateprogress")D="Validating progress";else if(Y==="acknowledge")D="Processing request";else if(Y==="finishplanning")D="Finalizing plan";else if(Y==="executetasks")D="Executing tasks";else if(Y==="requestuserinput")D="Waiting for input";else if(Y==="complete")D="Completed";else if(Y==="examinetool")D="Examining tool";else if(Y==="examineworkflow")D="Examining workflow";else{const J=(U==null?void 0:U.confidence)||.5;J>.8?D="Analyzing":J>.6?D="Thinking":D="Reasoning"}}else if(pe==="action_execution_result")((H=U==null?void 0:U.task_execution)==null?void 0:H.status)==="completed"?D="Task execution completed":(ne=U==null?void 0:U.task_execution)!=null&&ne.approach?D=U.task_execution.approach:D="Executing task";else if(pe==="assistant_task_breakdown")(me=U==null?void 0:U.task_breakdown)!=null&&me.total_tasks?D=`Identified ${U.task_breakdown.total_tasks} tasks`:D="Planning tasks";else if(pe==="assistant_validation")D="Validated results";else if(pe==="assistant_action_planning")(fe=U==null?void 0:U.task_execution)!=null&&fe.total_tasks?D=`Planned ${U.task_execution.total_tasks} tasks`:(N=(W=U==null?void 0:U.task_execution)==null?void 0:W.tasks)!=null&&N.length?D=`Planned ${U.task_execution.tasks.length} tasks`:D="Planning actions";else if(pe==="context_results"){const Y=U==null?void 0:U.query,ie=(U==null?void 0:U.result_count)||0;Y&&Y!=="General context gathering"?D=`${Y}: Found ${ie} results`:D=`Found ${ie} results`}se=D,ue={type:"log",messageType:pe}}return{id:Z.id,role:pe==="user_message"?"user":pe==="user_input_request"?"system":"assistant",content:se,images:xe,timestamp:new Date(Z.timestamp||Z.created_at||Date.now()),metadata:ue}}).filter(Z=>Z.content||Z.metadata||Z.images).sort((Z,se)=>{const xe=BigInt(Z.id),ue=BigInt(se.id);return xe<ue?-1:xe>ue?1:0});de.length>0&&(I.current=de[0].id),V?(c(Z=>[...de,...Z]),_(de.length>=50)):(c(de),de.length>0&&((q=de[de.length-1].metadata)==null?void 0:q.type)==="user_input_request"&&w(Le.WAITING_FOR_INPUT)),P(!1)}}}catch(te){console.error("Failed to fetch messages:",te),P(!1)}},[o,t,u]);a.useEffect(()=>{t&&o&&L()},[t,o]);const X=a.useCallback(async()=>{if(!(v||!C||!I.current)){P(!0);try{await L(I.current)}finally{P(!1)}}},[v,C,L]),ee=a.useCallback(()=>{!x||!b||(Xe.send({message_type:{cancel_execution:null},data:{}}),$(!1),w("idle"))},[x,b]);return{messages:f,pendingMessage:h,pendingImages:p,connectionState:y,isConnected:x,isExecuting:b,executionStatus:z,isWaitingForInput:z==="waiting_for_input",hasMoreMessages:C,isLoadingMore:v,sendMessage:A,submitUserInput:O,clearMessages:B,loadMoreMessages:X,cancelExecution:ee,connect:F,disconnect:()=>Xe.disconnect()}}const $c=()=>{const{client:t}=Fe(),[r,o]=a.useState(!1),[n,s]=a.useState(null),[i,u]=a.useState(null),f=a.useCallback(async h=>{o(!0),s(null),u(null);try{const l=await t("/organizations/invitations/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:h})}),g=(await G(l)).data;return u(g),g.error_code&&s(g.message||"Failed to accept invitation"),g}catch(l){const p=l.message||"Failed to accept invitation";s(p);const g={error_code:"NETWORK_ERROR",message:p};return u(g),g}finally{o(!1)}},[t]),c=a.useCallback(()=>{s(null),u(null)},[]);return{acceptInvitation:f,invitationData:i,loading:r,error:n,reset:c}},zu=({children:t})=>{const{loading:r}=ve();return r?null:e.jsx(e.Fragment,{children:t})},$u=({children:t})=>{const{loading:r}=ve();return r?e.jsx(e.Fragment,{children:t}):null};var Ye=function(){return Ye=Object.assign||function(r){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(r[i]=o[i])}return r},Ye.apply(this,arguments)};function tr(t,r,o){if(o||arguments.length===2)for(var n=0,s=r.length,i;n<s;n++)(i||!(n in r))&&(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return t.concat(i||Array.prototype.slice.call(r))}function Eu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var Iu=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Pu=Eu(function(t){return Iu.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ie="-ms-",Nr="-moz-",$e="-webkit-",Ec="comm",Ko="rule",js="decl",Ru="@import",Ic="@keyframes",Tu="@layer",Pc=Math.abs,_s=String.fromCharCode,is=Object.assign;function Mu(t,r){return We(t,0)^45?(((r<<2^We(t,0))<<2^We(t,1))<<2^We(t,2))<<2^We(t,3):0}function Rc(t){return t.trim()}function yt(t,r){return(t=r.exec(t))?t[0]:t}function ye(t,r,o){return t.replace(r,o)}function Io(t,r,o){return t.indexOf(r,o)}function We(t,r){return t.charCodeAt(r)|0}function yr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function Tc(t){return t.length}function Lr(t,r){return r.push(t),t}function Ou(t,r){return t.map(r).join("")}function Xs(t,r){return t.filter(function(o){return!yt(o,r)})}var Qo=1,wr=1,Mc=0,Je=0,De=0,Sr="";function Xo(t,r,o,n,s,i,u,f){return{value:t,root:r,parent:o,type:n,props:s,children:i,line:Qo,column:wr,length:u,return:"",siblings:f}}function $t(t,r){return is(Xo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function lr(t){for(;t.root;)t=$t(t.root,{children:[t]});Lr(t,t.siblings)}function Au(){return De}function Lu(){return De=Je>0?We(Sr,--Je):0,wr--,De===10&&(wr=1,Qo--),De}function rt(){return De=Je<Mc?We(Sr,Je++):0,wr++,De===10&&(wr=1,Qo++),De}function Kt(){return We(Sr,Je)}function Po(){return Je}function Jo(t,r){return yr(Sr,t,r)}function as(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Du(t){return Qo=wr=1,Mc=ct(Sr=t),Je=0,[]}function Nu(t){return Sr="",t}function xn(t){return Rc(Jo(Je-1,cs(t===91?t+2:t===40?t+1:t)))}function Fu(t){for(;(De=Kt())&&De<33;)rt();return as(t)>2||as(De)>3?"":" "}function Bu(t,r){for(;--r&&rt()&&!(De<48||De>102||De>57&&De<65||De>70&&De<97););return Jo(t,Po()+(r<6&&Kt()==32&&rt()==32))}function cs(t){for(;rt();)switch(De){case t:return Je;case 34:case 39:t!==34&&t!==39&&cs(De);break;case 40:t===41&&cs(t);break;case 92:rt();break}return Je}function Uu(t,r){for(;rt()&&t+De!==57;)if(t+De===84&&Kt()===47)break;return"/*"+Jo(r,Je-1)+"*"+_s(t===47?t:rt())}function Wu(t){for(;!as(Kt());)rt();return Jo(t,Je)}function Vu(t){return Nu(Ro("",null,null,null,[""],t=Du(t),0,[0],t))}function Ro(t,r,o,n,s,i,u,f,c){for(var h=0,l=0,p=u,g=0,x=0,m=0,b=1,$=1,z=1,w=0,y="",k=s,C=i,_=n,v=y;$;)switch(m=w,w=rt()){case 40:if(m!=108&&We(v,p-1)==58){Io(v+=ye(xn(w),"&","&\f"),"&\f",Pc(h?f[h-1]:0))!=-1&&(z=-1);break}case 34:case 39:case 91:v+=xn(w);break;case 9:case 10:case 13:case 32:v+=Fu(m);break;case 92:v+=Bu(Po()-1,7);continue;case 47:switch(Kt()){case 42:case 47:Lr(Gu(Uu(rt(),Po()),r,o,c),c);break;default:v+="/"}break;case 123*b:f[h++]=ct(v)*z;case 125*b:case 59:case 0:switch(w){case 0:case 125:$=0;case 59+l:z==-1&&(v=ye(v,/\f/g,"")),x>0&&ct(v)-p&&Lr(x>32?ei(v+";",n,o,p-1,c):ei(ye(v," ","")+";",n,o,p-2,c),c);break;case 59:v+=";";default:if(Lr(_=Js(v,r,o,h,l,s,f,y,k=[],C=[],p,i),i),w===123)if(l===0)Ro(v,r,_,_,k,i,p,f,C);else switch(g===99&&We(v,3)===110?100:g){case 100:case 108:case 109:case 115:Ro(t,_,_,n&&Lr(Js(t,_,_,0,0,s,f,y,s,k=[],p,C),C),s,C,p,f,n?k:C);break;default:Ro(v,_,_,_,[""],C,0,f,C)}}h=l=x=0,b=z=1,y=v="",p=u;break;case 58:p=1+ct(v),x=m;default:if(b<1){if(w==123)--b;else if(w==125&&b++==0&&Lu()==125)continue}switch(v+=_s(w),w*b){case 38:z=l>0?1:(v+="\f",-1);break;case 44:f[h++]=(ct(v)-1)*z,z=1;break;case 64:Kt()===45&&(v+=xn(rt())),g=Kt(),l=p=ct(y=v+=Wu(Po())),w++;break;case 45:m===45&&ct(v)==2&&(b=0)}}return i}function Js(t,r,o,n,s,i,u,f,c,h,l,p){for(var g=s-1,x=s===0?i:[""],m=Tc(x),b=0,$=0,z=0;b<n;++b)for(var w=0,y=yr(t,g+1,g=Pc($=u[b])),k=t;w<m;++w)(k=Rc($>0?x[w]+" "+y:ye(y,/&\f/g,x[w])))&&(c[z++]=k);return Xo(t,r,o,s===0?Ko:f,c,h,l,p)}function Gu(t,r,o,n){return Xo(t,r,o,Ec,_s(Au()),yr(t,2,-2),0,n)}function ei(t,r,o,n,s){return Xo(t,r,o,js,yr(t,0,n),yr(t,n+1,-1),n,s)}function Oc(t,r,o){switch(Mu(t,r)){case 5103:return $e+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return $e+t+t;case 4789:return Nr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return $e+t+Nr+t+Ie+t+t;case 5936:switch(We(t,r+11)){case 114:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return $e+t+Ie+t+t;case 6165:return $e+t+Ie+"flex-"+t+t;case 5187:return $e+t+ye(t,/(\w+).+(:[^]+)/,$e+"box-$1$2"+Ie+"flex-$1$2")+t;case 5443:return $e+t+Ie+"flex-item-"+ye(t,/flex-|-self/g,"")+(yt(t,/flex-|baseline/)?"":Ie+"grid-row-"+ye(t,/flex-|-self/g,""))+t;case 4675:return $e+t+Ie+"flex-line-pack"+ye(t,/align-content|flex-|-self/g,"")+t;case 5548:return $e+t+Ie+ye(t,"shrink","negative")+t;case 5292:return $e+t+Ie+ye(t,"basis","preferred-size")+t;case 6060:return $e+"box-"+ye(t,"-grow","")+$e+t+Ie+ye(t,"grow","positive")+t;case 4554:return $e+ye(t,/([^-])(transform)/g,"$1"+$e+"$2")+t;case 6187:return ye(ye(ye(t,/(zoom-|grab)/,$e+"$1"),/(image-set)/,$e+"$1"),t,"")+t;case 5495:case 3959:return ye(t,/(image-set\([^]*)/,$e+"$1$`$1");case 4968:return ye(ye(t,/(.+:)(flex-)?(.*)/,$e+"box-pack:$3"+Ie+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+$e+t+t;case 4200:if(!yt(t,/flex-|baseline/))return Ie+"grid-column-align"+yr(t,r)+t;break;case 2592:case 3360:return Ie+ye(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,s){return r=s,yt(n.props,/grid-\w+-end/)})?~Io(t+(o=o[r].value),"span",0)?t:Ie+ye(t,"-start","")+t+Ie+"grid-row-span:"+(~Io(o,"span",0)?yt(o,/\d+/):+yt(o,/\d+/)-+yt(t,/\d+/))+";":Ie+ye(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return yt(n.props,/grid-\w+-start/)})?t:Ie+ye(ye(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ye(t,/(.+)-inline(.+)/,$e+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ct(t)-1-r>6)switch(We(t,r+1)){case 109:if(We(t,r+4)!==45)break;case 102:return ye(t,/(.+:)(.+)-([^]+)/,"$1"+$e+"$2-$3$1"+Nr+(We(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~Io(t,"stretch",0)?Oc(ye(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ye(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,i,u,f,c,h){return Ie+s+":"+i+h+(u?Ie+s+"-span:"+(f?c:+c-+i)+h:"")+t});case 4949:if(We(t,r+6)===121)return ye(t,":",":"+$e)+t;break;case 6444:switch(We(t,We(t,14)===45?18:11)){case 120:return ye(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+$e+(We(t,14)===45?"inline-":"")+"box$3$1"+$e+"$2$3$1"+Ie+"$2box$3")+t;case 100:return ye(t,":",":"+Ie)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ye(t,"scroll-","scroll-snap-")+t}return t}function Do(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Hu(t,r,o,n){switch(t.type){case Tu:if(t.children.length)break;case Ru:case js:return t.return=t.return||t.value;case Ec:return"";case Ic:return t.return=t.value+"{"+Do(t.children,n)+"}";case Ko:if(!ct(t.value=t.props.join(",")))return""}return ct(o=Do(t.children,n))?t.return=t.value+"{"+o+"}":""}function qu(t){var r=Tc(t);return function(o,n,s,i){for(var u="",f=0;f<r;f++)u+=t[f](o,n,s,i)||"";return u}}function Yu(t){return function(r){r.root||(r=r.return)&&t(r)}}function Zu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case js:t.return=Oc(t.value,t.length,o);return;case Ic:return Do([$t(t,{value:ye(t.value,"@","@"+$e)})],n);case Ko:if(t.length)return Ou(o=t.props,function(s){switch(yt(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":lr($t(t,{props:[ye(s,/:(read-\w+)/,":"+Nr+"$1")]})),lr($t(t,{props:[s]})),is(t,{props:Xs(o,n)});break;case"::placeholder":lr($t(t,{props:[ye(s,/:(plac\w+)/,":"+$e+"input-$1")]})),lr($t(t,{props:[ye(s,/:(plac\w+)/,":"+Nr+"$1")]})),lr($t(t,{props:[ye(s,/:(plac\w+)/,Ie+"input-$1")]})),lr($t(t,{props:[s]})),is(t,{props:Xs(o,n)});break}return""})}}var Ku={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},rr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Ac="active",Lc="data-styled-version",en="6.1.19",ks=`/*!sc*/
19
- `,No=typeof window<"u"&&typeof document<"u",Qu=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==""?process.env.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&process.env.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.SC_DISABLE_SPEEDY!==void 0&&process.env.SC_DISABLE_SPEEDY!==""?process.env.SC_DISABLE_SPEEDY!=="false"&&process.env.SC_DISABLE_SPEEDY:process.env.NODE_ENV!=="production"),ti=/invalid hook call/i,Jr=new Set,Xu=function(t,r){if(process.env.NODE_ENV!=="production"){var o=r?' with the id of "'.concat(r,'"'):"",n="The component ".concat(t).concat(o,` has been created dynamically.
18
+ */var Ws;function jd(){return Ws||(Ws=1,process.env.NODE_ENV!=="production"&&function(){function t(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}function r(v,x){l||s.startTransition===void 0||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var w=x();if(!u){var $=x();a(w,$)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}$=p({inst:{value:w,getSnapshot:x}});var S=$[0].inst,k=$[1];return c(function(){S.value=w,S.getSnapshot=x,o(S)&&k({inst:S})},[v,w,x]),f(function(){return o(S)&&k({inst:S}),v(function(){o(S)&&k({inst:S})})},[v]),h(w),w}function o(v){var x=v.getSnapshot;v=v.value;try{var w=x();return!a(v,w)}catch{return!0}}function n(v,x){return x()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=i,a=typeof Object.is=="function"?Object.is:t,p=s.useState,f=s.useEffect,c=s.useLayoutEffect,h=s.useDebugValue,l=!1,u=!1,g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;dn.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())}()),dn}var Vs;function _d(){return Vs||(Vs=1,process.env.NODE_ENV==="production"?Kr.exports=wd():Kr.exports=jd()),Kr.exports}var kd=_d();const sc=0,ac=1,ic=2,Gs=3;var Hs=Object.prototype.hasOwnProperty;function Kn(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&Kn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Hs.call(t,o)&&++n&&!Hs.call(r,o)||!(o in r)||!Kn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const jt=new WeakMap,$t=()=>{},qe=$t(),Qn=Object,Se=t=>t===qe,lt=t=>typeof t=="function",It=(t,r)=>({...t,...r}),cc=t=>lt(t.then),un={},Qr={},ys="undefined",Vr=typeof window!=ys,Xn=typeof document!=ys,Cd=Vr&&"Deno"in window,Sd=()=>Vr&&typeof window.requestAnimationFrame!=ys,lc=(t,r)=>{const o=jt.get(t);return[()=>!Se(r)&&t.get(r)||un,n=>{if(!Se(r)){const s=t.get(r);r in Qr||(Qr[r]=s),o[5](r,It(s,n),s||un)}},o[6],()=>!Se(r)&&r in Qr?Qr[r]:!Se(r)&&t.get(r)||un]};let Jn=!0;const zd=()=>Jn,[es,ts]=Vr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$t,$t],$d=()=>{const t=Xn&&document.visibilityState;return Se(t)||t!=="hidden"},Ed=t=>(Xn&&document.addEventListener("visibilitychange",t),es("focus",t),()=>{Xn&&document.removeEventListener("visibilitychange",t),ts("focus",t)}),Id=t=>{const r=()=>{Jn=!0,t()},o=()=>{Jn=!1};return es("online",r),es("offline",o),()=>{ts("online",r),ts("offline",o)}},Pd={isOnline:zd,isVisible:$d},Rd={initFocus:Ed,initReconnect:Id},qs=!i.useId,Fr=!Vr||Cd,Td=t=>Sd()?window.requestAnimationFrame(t):setTimeout(t,1),pn=Fr?i.useEffect:i.useLayoutEffect,hn=typeof navigator<"u"&&navigator.connection,Ys=!Fr&&hn&&(["slow-2g","2g"].includes(hn.effectiveType)||hn.saveData),Xr=new WeakMap,Md=t=>Qn.prototype.toString.call(t),fn=(t,r)=>t===`[object ${r}]`;let Od=0;const rs=t=>{const r=typeof t,o=Md(t),n=fn(o,"Date"),s=fn(o,"RegExp"),a=fn(o,"Object");let p,f;if(Qn(t)===t&&!n&&!s){if(p=Xr.get(t),p)return p;if(p=++Od+"~",Xr.set(t,p),Array.isArray(t)){for(p="@",f=0;f<t.length;f++)p+=rs(t[f])+",";Xr.set(t,p)}if(a){p="#";const c=Qn.keys(t).sort();for(;!Se(f=c.pop());)Se(t[f])||(p+=f+":"+rs(t[f])+",");Xr.set(t,p)}}else p=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return p},ws=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?rs(t):"",[t,r]};let Ad=0;const os=()=>++Ad;async function dc(...t){const[r,o,n,s]=t,a=It({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let p=a.populateCache;const f=a.rollbackOnError;let c=a.optimisticData;const h=g=>typeof f=="function"?f(g):f!==!1,l=a.throwOnError;if(lt(o)){const g=o,v=[],x=r.keys();for(const w of x)!/^\$(inf|sub)\$/.test(w)&&g(r.get(w)._k)&&v.push(w);return Promise.all(v.map(u))}return u(o);async function u(g){const[v]=ws(g);if(!v)return;const[x,w]=lc(r,v),[$,S,k,P]=jt.get(r),E=()=>{const I=$[v];return(lt(a.revalidate)?a.revalidate(x().data,g):a.revalidate!==!1)&&(delete k[v],delete P[v],I&&I[0])?I[0](ic).then(()=>x().data):x().data};if(t.length<3)return E();let z=n,y,m=!1;const b=os();S[v]=[b,0];const _=!Se(c),j=x(),T=j.data,R=j._c,C=Se(R)?T:R;if(_&&(c=lt(c)?c(C,T):c,w({data:c,_c:C})),lt(z))try{z=z(C)}catch(I){y=I,m=!0}if(z&&cc(z))if(z=await z.catch(I=>{y=I,m=!0}),b!==S[v][0]){if(m)throw y;return z}else m&&_&&h(y)&&(p=!0,w({data:C,_c:qe}));if(p&&!m)if(lt(p)){const I=p(z,C);w({data:I,error:qe,_c:qe})}else w({data:z,error:qe,_c:qe});if(S[v][1]=os(),Promise.resolve(E()).then(()=>{w({_c:qe})}),m){if(l)throw y;return}return z}}const Zs=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},Ld=(t,r)=>{if(!jt.has(t)){const o=It(Rd,r),n=Object.create(null),s=dc.bind(qe,t);let a=$t;const p=Object.create(null),f=(l,u)=>{const g=p[l]||[];return p[l]=g,g.push(u),()=>g.splice(g.indexOf(u),1)},c=(l,u,g)=>{t.set(l,u);const v=p[l];if(v)for(const x of v)x(u,g)},h=()=>{if(!jt.has(t)&&(jt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),s,c,f]),!Fr)){const l=o.initFocus(setTimeout.bind(qe,Zs.bind(qe,n,sc))),u=o.initReconnect(setTimeout.bind(qe,Zs.bind(qe,n,ac)));a=()=>{l&&l(),u&&u(),jt.delete(t)}}};return h(),[t,s,h,a]}return[t,jt.get(t)[4]]},Dd=(t,r,o,n,s)=>{const a=o.errorRetryCount,p=s.retryCount,f=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!Se(a)&&p>a||setTimeout(n,f,s)},Nd=Kn,[uc,Or]=Ld(new Map),Fd=It({onLoadingSlow:$t,onSuccess:$t,onError:$t,onErrorRetry:Dd,onDiscarded:$t,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ys?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ys?5e3:3e3,compare:Nd,isPaused:()=>!1,cache:uc,mutate:Or,fallback:{}},Pd),Bd=(t,r)=>{const o=It(t,r);if(r){const{use:n,fallback:s}=t,{use:a,fallback:p}=r;n&&a&&(o.use=n.concat(a)),s&&p&&(o.fallback=It(s,p))}return o},Ud=i.createContext({}),Wd="$inf$",pc=Vr&&window.__SWR_DEVTOOLS_USE__,Vd=pc?window.__SWR_DEVTOOLS_USE__:[],Gd=()=>{pc&&(window.__SWR_DEVTOOLS_REACT__=i)},Hd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],hc=()=>It(Fd,i.useContext(Ud)),qd=t=>(r,o,n)=>t(r,o&&((...a)=>{const[p]=ws(r),[,,,f]=jt.get(uc);if(p.startsWith(Wd))return o(...a);const c=f[p];return Se(c)?o(...a):(delete f[p],c)}),n),Yd=Vd.concat(qd),Zd=t=>function(...o){const n=hc(),[s,a,p]=Hd(o),f=Bd(n,p);let c=t;const{use:h}=f,l=(h||[]).concat(Yd);for(let u=l.length;u--;)c=l[u](c);return c(s,a||f.fetcher||null,f)},Kd=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const s=n.indexOf(o);s>=0&&(n[s]=n[n.length-1],n.pop())}};Gd();const gn=i.use||(t=>{switch(t.status){case"pending":throw t;case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t.status="pending",t.then(r=>{t.status="fulfilled",t.value=r},r=>{t.status="rejected",t.reason=r}),t}}),mn={dedupe:!0},Qd=(t,r,o)=>{const{cache:n,compare:s,suspense:a,fallbackData:p,revalidateOnMount:f,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:g}=o,[v,x,w,$]=jt.get(n),[S,k]=ws(t),P=i.useRef(!1),E=i.useRef(!1),z=i.useRef(S),y=i.useRef(r),m=i.useRef(o),b=()=>m.current,_=()=>b().isVisible()&&b().isOnline(),[j,T,R,C]=lc(n,S),I=i.useRef({}).current,M=Se(p)?Se(o.fallback)?qe:o.fallback[S]:p,F=(ue,U)=>{for(const pe in I){const K=pe;if(K==="data"){if(!s(ue[K],U[K])&&(!Se(ue[K])||!s(re,U[K])))return!1}else if(U[K]!==ue[K])return!1}return!0},L=i.useMemo(()=>{const ue=!S||!r?!1:Se(f)?b().isPaused()||a?!1:c!==!1:f,U=fe=>{const W=It(fe);return delete W._k,ue?{isValidating:!0,isLoading:!0,...W}:W},pe=j(),K=C(),H=U(pe),se=pe===K?H:U(K);let me=H;return[()=>{const fe=U(j());return F(fe,me)?(me.data=fe.data,me.isLoading=fe.isLoading,me.isValidating=fe.isValidating,me.error=fe.error,me):(me=fe,fe)},()=>se]},[n,S]),B=kd.useSyncExternalStore(i.useCallback(ue=>R(S,(U,pe)=>{F(pe,U)||ue()}),[n,S]),L[0],L[1]),O=!P.current,A=v[S]&&v[S].length>0,X=B.data,te=Se(X)?M&&cc(M)?gn(M):M:X,V=B.error,q=i.useRef(te),re=g?Se(X)?Se(q.current)?te:q.current:X:te,ne=A&&!Se(V)?!1:O&&!Se(f)?f:b().isPaused()?!1:a?Se(te)?!1:c:Se(te)||c,J=!!(S&&r&&O&&ne),oe=Se(B.isValidating)?J:B.isValidating,de=Se(B.isLoading)?J:B.isLoading,Z=i.useCallback(async ue=>{const U=y.current;if(!S||!U||E.current||b().isPaused())return!1;let pe,K,H=!0;const se=ue||{},me=!w[S]||!se.dedupe,fe=()=>qs?!E.current&&S===z.current&&P.current:S===z.current,W={isValidating:!1,isLoading:!1},N=()=>{T(W)},D=()=>{const ie=w[S];ie&&ie[1]===K&&delete w[S]},Y={isValidating:!0};Se(j().data)&&(Y.isLoading=!0);try{if(me&&(T(Y),o.loadingTimeout&&Se(j().data)&&setTimeout(()=>{H&&fe()&&b().onLoadingSlow(S,o)},o.loadingTimeout),w[S]=[U(k),os()]),[pe,K]=w[S],pe=await pe,me&&setTimeout(D,o.dedupingInterval),!w[S]||w[S][1]!==K)return me&&fe()&&b().onDiscarded(S),!1;W.error=qe;const ie=x[S];if(!Se(ie)&&(K<=ie[0]||K<=ie[1]||ie[1]===0))return N(),me&&fe()&&b().onDiscarded(S),!1;const ee=j().data;W.data=s(ee,pe)?ee:pe,me&&fe()&&b().onSuccess(pe,S,o)}catch(ie){D();const ee=b(),{shouldRetryOnError:_e}=ee;ee.isPaused()||(W.error=ie,me&&fe()&&(ee.onError(ie,S,ee),(_e===!0||lt(_e)&&_e(ie))&&(!b().revalidateOnFocus||!b().revalidateOnReconnect||_())&&ee.onErrorRetry(ie,S,ee,be=>{const ze=v[S];ze&&ze[0]&&ze[0](Gs,be)},{retryCount:(se.retryCount||0)+1,dedupe:!0})))}return H=!1,N(),!0},[S,n]),ae=i.useCallback((...ue)=>dc(n,z.current,...ue),[]);if(pn(()=>{y.current=r,m.current=o,Se(X)||(q.current=X)}),pn(()=>{if(!S)return;const ue=Z.bind(qe,mn);let U=0;b().revalidateOnFocus&&(U=Date.now()+b().focusThrottleInterval);const K=Kd(S,v,(H,se={})=>{if(H==sc){const me=Date.now();b().revalidateOnFocus&&me>U&&_()&&(U=me+b().focusThrottleInterval,ue())}else if(H==ac)b().revalidateOnReconnect&&_()&&ue();else{if(H==ic)return Z();if(H==Gs)return Z(se)}});return E.current=!1,z.current=S,P.current=!0,T({_k:k}),ne&&(w[S]||(Se(te)||Fr?ue():Td(ue))),()=>{E.current=!0,K()}},[S]),pn(()=>{let ue;function U(){const K=lt(h)?h(j().data):h;K&&ue!==-1&&(ue=setTimeout(pe,K))}function pe(){!j().error&&(l||b().isVisible())&&(u||b().isOnline())?Z(mn).then(U):U()}return U(),()=>{ue&&(clearTimeout(ue),ue=-1)}},[h,l,u,S]),i.useDebugValue(re),a&&Se(te)&&S){if(!qs&&Fr)throw new Error("Fallback data is required when using Suspense in SSR.");y.current=r,m.current=o,E.current=!1;const ue=$[S];if(!Se(ue)){const U=ae(ue);gn(U)}if(Se(V)){const U=Z(mn);Se(re)||(U.status="fulfilled",U.value=!0),gn(U)}else throw V}return{mutate:ae,get data(){return I.data=!0,re},get error(){return I.error=!0,V},get isValidating(){return I.isValidating=!0,oe},get isLoading(){return I.isLoading=!0,de}}},Fe=Zd(Qd);async function G(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}return{data:(await t.json()).data}}function fc(t){const{client:r}=Be(),o=i.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await G(c)).data},[r,t]),{data:n,error:s,mutate:a}=Fe(t?`wacht-agent-sessions:${t}`:null,o,{revalidateOnFocus:!1}),p=i.useCallback(async c=>{const h=new FormData;h.append("title",c.title),c.system_instructions&&h.append("system_instructions",c.system_instructions);const l=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:h}),u=await G(l);return await a(g=>g&&{...g,data:[u.data,...g.data]}),u.data},[r,t,a]),f=i.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await a(h=>h&&{...h,data:h.data.filter(l=>l.id!==c)})},[r,t,a]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!s,error:s,createSession:p,deleteSession:f,refetch:async()=>{await a()}}}const gc=i.createContext(void 0);function qo(){const t=i.useContext(gc);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Xd({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:s,onSessionCreated:a,onSessionDeleted:p,onError:f}){const[c,h]=i.useState(s?{id:s,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[l,u]=i.useState(!1),{sessions:g,loading:v,error:x,createSession:w,deleteSession:$,refetch:S}=fc(o);i.useEffect(()=>{if(s&&g.length>0){const y=g.find(m=>m.id===s);y&&h(y)}},[s,g]);const k=i.useCallback(y=>{h(y),u(!1)},[]),P=i.useCallback(async y=>{try{const m=y||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,b=await w({title:m});return h(b),a==null||a(b),b}catch(m){const b=m instanceof Error?m.message:"Failed to create session";throw f==null||f(b),m}},[w,a,f]),E=i.useCallback(async y=>{try{await $(y),(c==null?void 0:c.id)===y&&h(null),p==null||p(y)}catch(m){const b=m instanceof Error?m.message:"Failed to delete session";throw f==null||f(b),m}},[$,c,p,f]),z={agentName:r,token:o,platformAdapter:n,sessions:g,selectedSession:c,loadingSessions:v,sessionError:x,selectSession:k,createSession:P,deleteSession:E,refreshSessions:S,showHistory:l,setShowHistory:u,onSessionCreated:a,onSessionDeleted:p,onError:f};return e.jsx(gc.Provider,{value:z,children:t})}var mc=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(mc||{});function Jd(t,r){const o={username:eu(t,r),email:tu(t,r),phone:ru(t,r),email_otp:ou(t,r),magic_link:nu(t,r),oauth:su(t),generic:au(t,r)};return function(s){return o[s]}}function eu(t,r){return async({username:o,password:n})=>{var f,c;const s=new FormData;s.append("strategy","plain_username"),s.append("username",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),p=await G(a);return"data"in p&&((c=(f=p.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function tu(t,r){return async({email:o,password:n})=>{var f,c;const s=new FormData;s.append("strategy","plain_email"),s.append("email",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),p=await G(a);return"data"in p&&((c=(f=p.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function ru(t,r){return async({phone:o})=>{var p,f;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await G(s);return"data"in a&&((f=(p=a.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function ou(t,r){return async({email:o})=>{var p,f;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await G(s);return"data"in a&&((f=(p=a.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function nu(t,r){return async({email:o})=>{var p,f;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await G(s);return"data"in a&&((f=(p=a.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function su(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const s=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),a=await G(s);return"data"in a&&a.data.oauth_url&&(window.location.href=a.data.oauth_url),a}}function au(t,r){return async({email:o,username:n,password:s,phone:a,strategy:p,token:f})=>{var u,g;const c=new FormData;p&&c.append("strategy",p),o&&c.append("email",o),n&&c.append("username",n),s&&c.append("password",s),a&&c.append("phone",a),f&&c.append("token",f);const h=await t("/auth/signin",{method:"POST",body:c}),l=await G(h);return"data"in l&&((g=(u=l.data)==null?void 0:u.signin_attempts)!=null&&g.length)&&r(l.data.signin_attempts.at(-1)||null),l}}function xc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Jd(t,n),completeVerification:async s=>{var c,h;const a=new FormData;a.append("verification_code",s);const p=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:a}),f=await G(p);if("data"in f&&((h=(c=f.data)==null?void 0:c.signin_attempts)!=null&&h.length)){const l=f.data.signin_attempts.at(-1);return n(l||null),f.data}else throw new Error("Verification failed")},prepareVerification:async s=>{var f;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((f=o==null?void 0:o.id)==null?void 0:f.toString())||""),a.searchParams.set("strategy",s.strategy),a.searchParams.set("identifier_type","signin"),s.strategy==="phone_otp"&&s.lastDigits?a.searchParams.set("last_digits",s.lastDigits):(s.strategy==="email_otp"&&s.redirectUri||s.strategy==="magic_link"&&s.redirectUri)&&a.searchParams.set("redirect_uri",s.redirectUri);const p=await t(a.pathname+a.search,{method:"POST"});return G(p)},completeProfile:async s=>{var c;if(!o)throw new Error("No signin attempt found");const a=new FormData;for(const[h,l]of Object.entries(s))l&&a.append(h,l);const p=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:a}),f=await G(p);if("data"in f&&f.data){const h=(c=f.data.signin_attempts)==null?void 0:c.find(l=>l.id===o.id);return h&&n(h),f.data}else throw new Error("Profile completion failed")},identify:async s=>{const a=new FormData;a.append("identifier",s);const p=await t("/auth/identify",{method:"POST",body:a});return(await G(p)).data},initEnterpriseSso:async(s,a)=>{const p=new URLSearchParams({connection_id:s});a&&p.append("redirect_uri",a);const f=await t(`/auth/sso/login?${p.toString()}`,{method:"POST"});return(await G(f)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function Br(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:s,setSignInAttempt:a}=xc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:s,setSignInAttempt:a};const p=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:p,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:s,setSignInAttempt:a}}function iu(t,r,o){return{create:async n=>{var f,c,h;const s=new FormData;for(const[l,u]of Object.entries(n))s.append(l,u);const a=await t("/auth/signup",{method:"POST",body:s}),p=await G(a);return"data"in p&&((c=(f=p.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(((h=p.data.signup_attempts)==null?void 0:h.at(-1))||null),p},prepareVerification:async n=>{var p;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((p=r==null?void 0:r.id)==null?void 0:p.toString())||""),s.searchParams.set("strategy",n.strategy),s.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?s.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&s.searchParams.set("redirect_uri",n.redirectUri);const a=await t(s.pathname+s.search,{method:"POST"});return G(a)},completeVerification:async n=>{var f,c;const s=new FormData;s.append("verification_code",n);const a=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),p=await G(a);return"data"in p&&((c=(f=p.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(p.data.signup_attempts.at(-1)||null),p},validateDeploymentInvitation:async n=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),a=await G(s);return"data"in a&&a.data?a.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(s){return{valid:!1,message:s.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function vc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:iu(t,o,n)}}const Ge=()=>{const{adapter:t,deployment:r}=ve(),o=t.useNavigate(),n=(c,h)=>{o?o(c,h):window.location.href=c},s=c=>{if(c)return c;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function cu(t){const r=await t("/session",{method:"GET"});return(await G(r)).data}async function lu(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return G(o)}async function du(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return G(n)}async function uu(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return G(o)}async function pu(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return G(o)}const ns=new Map,Ar=new Map;function _t(){ns.clear(),Ar.clear()}async function hu(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return G(o)}function Ue(){const{client:t,loading:r}=Be(),{deployment:o}=ve(),{navigate:n}=Ge(),{cache:s}=hc(),{data:a,error:p,mutate:f,isLoading:c}=Fe(r?null:"/session",()=>cu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=i.useCallback(async()=>{await f(void 0,{revalidate:!0})},[f]),l=i.useCallback(async(u="default")=>{if(!a)throw new Error("no session");const g=ns.get(u);if(g&&g.expires>Date.now())return(g==null?void 0:g.token)||"";Ar.get(u)||Ar.set(u,hu(t,u));const v=await Ar.get(u);return Ar.delete(u),ns.set(u,v.data),v.data.token},[t,a==null?void 0:a.active_signin]);return r||!a||c?{loading:!0,error:p,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:h}:{loading:c,error:p,session:a,switchSignIn:async u=>{await lu(t,u),_t(),await Or("/me/organization-memberships",void 0,{revalidate:!1}),await Or("/me/workspace-memberships",void 0,{revalidate:!1}),await f(void 0,{revalidate:!0}),await Or("/me/organization-memberships"),await Or("/me/workspace-memberships")},signOut:async u=>{await du(t,u);const g=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],v=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(s instanceof Map){const x=Array.from(s.keys());for(const w of x){let $=!1;(g.includes(w)||typeof w=="string"&&v.some(S=>w.startsWith(S)))&&($=!0),$&&s.delete(w)}}_t(),await f(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(u&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!u&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async u=>{await uu(t,u),_t(),await f(void 0,{revalidate:!0})},switchWorkspace:async u=>{await pu(t,u),_t(),await f(void 0,{revalidate:!0})},getToken:l,refetch:h}}const Yo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=Ct(),{client:n}=Be(),{refetch:s}=Ue(),a=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/roles`,{method:"GET"}))).data,[n]),p=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/members`,{method:"GET"}))).data,[n]),f=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/domains`,{method:"GET"}))).data,[n]),h=i.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/members/${O.id}/remove`,{method:"POST"})},[n]),l=i.useCallback(async B=>{const O=new FormData;O.append("name",B.name),B.image&&O.append("image",B.image),B.description&&O.append("description",B.description);const A=await G(await n("/organizations",{method:"POST",body:O}));return _t(),await r(),await s(),A},[s,r,n]),u=i.useCallback(async(B,O)=>{const A=Object.entries(O).reduce((te,[V,q])=>(q&&te.append(V,q),te),new FormData),X=await G(await n(`/organizations/${B.id}/update`,{method:"POST",body:A}));return await r(),X},[r,n]),g=i.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/roles/${O.id}/remove`,{method:"POST"})},[n]),v=i.useCallback(async(B,O)=>{const A=new FormData;return A.append("domain",O.fqdn),await G(await n(`/organizations/${B.id}/domains`,{method:"POST",body:A}))},[n]),x=i.useCallback(async(B,O)=>await G(await n(`/organizations/${B.id}/domains/${O.id}/verify`,{method:"POST"})),[n]),w=i.useCallback(async(B,O)=>await G(await n(`/organizations/${B.id}/domains/${O.id}/delete`,{method:"POST"})),[n]),$=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/enterprise-connections`,{method:"GET"}))).data,[n]),S=i.useCallback(async(B,O)=>{const A=new FormData;return A.append("protocol",O.protocol),O.domain_id&&A.append("domain_id",O.domain_id),O.idp_entity_id&&A.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&A.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&A.append("idp_certificate",O.idp_certificate),O.oidc_client_id&&A.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&A.append("oidc_client_secret",O.oidc_client_secret),O.oidc_issuer_url&&A.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_scopes&&A.append("oidc_scopes",O.oidc_scopes),O.jit_enabled!==void 0&&A.append("jit_enabled",String(O.jit_enabled)),O.attribute_mapping&&A.append("attribute_mapping",JSON.stringify(O.attribute_mapping)),(await G(await n(`/organizations/${B.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),k=i.useCallback(async(B,O,A)=>{const X=new FormData;return A.domain_id&&X.append("domain_id",A.domain_id),A.idp_entity_id&&X.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&X.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&X.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&X.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&X.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&X.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&X.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&X.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/update`,{method:"POST",body:X}))).data},[n]),P=i.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/enterprise-connections/${O}/delete`,{method:"POST"})},[n]),E=i.useCallback(async(B,O)=>{const A=new FormData;return A.append("protocol",O.protocol),O.idp_entity_id&&A.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&A.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&A.append("idp_certificate",O.idp_certificate),O.oidc_issuer_url&&A.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_client_id&&A.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&A.append("oidc_client_secret",O.oidc_client_secret),(await G(await n(`/organizations/${B.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),z=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/test`,{method:"POST"}))).data,[n]),y=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/scim/token`,{method:"POST"}))).data,[n]),m=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/scim/token`,{method:"GET"}))).data,[n]),b=i.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/enterprise-connections/${O}/scim/token/revoke`,{method:"POST"})},[n]),_=i.useCallback(async(B,O)=>{const A=new FormData;return A.append("name",O.name),O.permissions&&O.permissions.forEach((te,V)=>{A.append(`permissions[${V}]`,te)}),await G(await n(`/organizations/${B.id}/roles`,{method:"POST",body:A}))},[n]),j=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/leave`,{method:"POST"}))).data,[n]),T=i.useCallback(async B=>{const O=await G(await n(`/organizations/${B.id}/delete`,{method:"POST"}));return _t(),await r(),await s(),O.data},[n,r,s]),R=i.useCallback(async(B,O,A)=>(await G(await n(`/organizations/${B.id}/members/${O.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),C=i.useCallback(async(B,O,A)=>(await G(await n(`/organizations/${B.id}/members/${O.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),I=i.useCallback(async(B,O)=>{var te,V;const A=new FormData;return A.append("email",O.email),A.append("role_id",O.organizationRole.id),(te=O.workspace)!=null&&te.id&&A.append("workspace_id",O.workspace.id),(V=O.workspaceRole)!=null&&V.id&&A.append("workspace_role_id",O.workspaceRole.id),(await G(await n(`/organizations/${B.id}/invitations`,{method:"POST",body:A}))).data},[n]),M=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/invitations/${O.id}/discard`,{method:"POST"}))).data,[n]),F=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/invitations/${O.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(B=>B.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:j,getOrganizationRoles:a,getOrganizationMembers:p,removeOrganizationMember:h,createOrganization:l,getOrganizationInvitations:f,getOrganizationDomains:c,addOrganizationDomain:v,verifyOrganizationDomain:x,removeOrganizationDomain:w,addRoleToOrganizationMember:R,removeRoleFromOrganizationMember:C,inviteOrganizationMember:I,discardOrganizationInvitation:M,resendOrganizationInvitation:F,updateOrganization:u,addRole:_,removeOrganizationRoles:g,deleteOrganization:T,getEnterpriseConnections:$,createEnterpriseConnection:S,updateEnterpriseConnection:k,deleteEnterpriseConnection:P,testEnterpriseConnectionConfig:E,testEnterpriseConnection:z,generateSCIMToken:y,getSCIMToken:m,revokeSCIMToken:b}},Ze=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:s,leaveOrganization:a,removeOrganizationMember:p,getOrganizationInvitations:f,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:l,verifyOrganizationDomain:u,addRoleToOrganizationMember:g,removeRoleFromOrganizationMember:v,inviteOrganizationMember:x,discardOrganizationInvitation:w,resendOrganizationInvitation:$,updateOrganization:S,removeOrganizationRoles:k,getEnterpriseConnections:P,createEnterpriseConnection:E,updateEnterpriseConnection:z,deleteEnterpriseConnection:y,testEnterpriseConnectionConfig:m,testEnterpriseConnection:b,generateSCIMToken:_,getSCIMToken:j,revokeSCIMToken:T}=Yo(),{session:R,error:C,loading:I}=Ue(),{organizationMemberships:M}=Ct(),F=i.useMemo(()=>(M==null?void 0:M.find(D=>{var Y;return D.id===((Y=R==null?void 0:R.active_signin)==null?void 0:Y.active_organization_membership_id)}))||null,[M,R]),L=i.useMemo(()=>(F==null?void 0:F.organization)||null,[F]),B=i.useCallback(async D=>L?await S(L,D):[],[L,S]),O=i.useCallback(async()=>L?await n(L):[],[L,n]),A=i.useCallback(async()=>L?await s(L):[],[L,s]),X=i.useCallback(async D=>L?await p(L,D):[],[L,p]),te=i.useCallback(async D=>L?await k(L,D):void 0,[L,k]),V=i.useCallback(async()=>L?await c(L):[],[L,c]),q=i.useCallback(async D=>L?await l(L,D):void 0,[L,l]),re=i.useCallback(async D=>L?await u(L,D):void 0,[L,u]),ne=i.useCallback(async D=>L?await h(L,D):void 0,[L,h]),J=i.useCallback(async(D,Y)=>L?await g(L,D,Y):void 0,[L,g]),oe=i.useCallback(async(D,Y)=>L?await v(L,D,Y):void 0,[L,v]),de=i.useCallback(async D=>L?await x(L,D):void 0,[L,x]),Z=i.useCallback(async D=>L?await w(L,D):void 0,[L,w]),ae=i.useCallback(async D=>L?await $(L,D):void 0,[L,$]),xe=i.useCallback(async()=>{L&&await a(L)},[L,a]),ue=i.useCallback(async()=>L?await f(L):[],[L,f]),U=i.useCallback(async()=>L?await P(L):[],[L,P]),pe=i.useCallback(async D=>{if(L)return await E(L,D)},[L,E]),K=i.useCallback(async(D,Y)=>{if(L)return await z(L,D,Y)},[L,z]),H=i.useCallback(async D=>{L&&await y(L,D)},[L,y]),se=i.useCallback(async D=>L?await m(L,D):null,[L,m]),me=i.useCallback(async D=>L?await b(L,D):null,[L,b]),fe=i.useCallback(async D=>{if(L)return await _(L,D)},[L,_]),W=i.useCallback(async D=>{if(L)return await j(L,D)},[L,j]),N=i.useCallback(async D=>{L&&await T(L,D)},[L,T]);return I||t?{activeOrganization:null,activeMembership:null,loading:!0,error:C||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:L,activeMembership:F,loading:!1,refetch:o,getRoles:A,updateOrganization:B,getMembers:O,getDomains:V,addDomain:q,verifyDomain:re,removeDomain:ne,getInvitations:ue,removeMember:X,leave:xe,removeRole:te,addMemberRole:J,removeMemberRole:oe,inviteMember:de,discardInvitation:Z,resendInvitation:ae,getEnterpriseConnections:U,createEnterpriseConnection:pe,updateEnterpriseConnection:K,deleteEnterpriseConnection:H,testEnterpriseConnectionConfig:se,testEnterpriseConnection:me,generateSCIMToken:fe,getSCIMToken:W,revokeSCIMToken:N,error:null}};async function fu(t){return(await G(await t("/me/organization-memberships"))).data}const Ct=()=>{const{client:t,loading:r}=Be(),{data:o,isLoading:n,error:s,mutate:a}=Fe(r?null:"/me/organization-memberships",()=>fu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),p=i.useCallback(async()=>{await a(void 0,{revalidate:!0})},[a]);return{organizationMemberships:o,loading:r||n,error:s,refetch:p}};async function gu(t){return(await G(await t("/me/workspace-memberships"))).data}async function mu(t,r,o){return(await G(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Zo=()=>{const{client:t,loading:r}=Be(),{deployment:o}=ve(),{data:n,isLoading:s,error:a,mutate:p}=Fe(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>gu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]);return{workspaceMemberships:n,loading:r||s,error:a,refetch:f}},Pt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Zo(),{client:s}=Be(),a=i.useMemo(()=>t==null?void 0:t.map(y=>({...y.workspace,organization:y.organization,eligibility_restriction:y.eligibility_restriction})),[t]),p=i.useCallback(async(y,m,b,_)=>{const j=new FormData;j.append("name",m),b&&j.append("image",b),_&&j.append("description",_),j.append("organization_id",y);const T=await G(await s("/workspaces",{method:"POST",body:j}));return _t(),await r(),T.data},[s,r]),f=i.useCallback(async(y,m)=>{const b=await mu(s,y,m);return await r(),b},[s,r]),c=i.useCallback(async(y,m)=>{const b=new FormData;m.name&&b.append("name",m.name),m.description&&b.append("description",m.description),m.image&&b.append("image",m.image),m.enforce_2fa!==void 0&&b.append("enforce_2fa",String(m.enforce_2fa)),m.enable_ip_restriction!==void 0&&b.append("enable_ip_restriction",String(m.enable_ip_restriction)),m.whitelisted_ips&&m.whitelisted_ips.forEach(j=>b.append("whitelisted_ips",j));const _=await G(await s(`/workspaces/${y.id}/update`,{method:"POST",body:b}));return await r(),_.data},[s,r]),h=i.useCallback(async y=>{const m=await G(await s(`/workspaces/${y.id}/delete`,{method:"POST"}));return _t(),await r(),m.data},[s,r]),l=i.useCallback(async y=>(await G(await s(`/workspaces/${y.id}/members`,{method:"GET"}))).data,[s]),u=i.useCallback(async y=>(await G(await s(`/workspaces/${y.id}/roles`,{method:"GET"}))).data,[s]),g=i.useCallback(async(y,m,b)=>{const _=new FormData;return _.append("name",m),b.forEach(T=>_.append("permissions",T)),(await G(await s(`/workspaces/${y.id}/roles`,{method:"POST",body:_}))).data},[s]),v=i.useCallback(async(y,m)=>(await G(await s(`/workspaces/${y.id}/roles/${m.id}/delete`,{method:"POST"}))).data,[s]),x=i.useCallback(async(y,m,b)=>{const _=new FormData;return _.append("email",m),b&&_.append("role_id",b),(await G(await s(`/workspaces/${y.id}/members`,{method:"POST",body:_}))).data},[s]),w=i.useCallback(async(y,m)=>{const b=await G(await s(`/workspaces/${y.id}/members/${m}/remove`,{method:"POST"}));return await r(),b.data},[s,r]),$=i.useCallback(async(y,m,b)=>(await G(await s(`/workspaces/${y.id}/members/${m}/roles/${b}/add`,{method:"POST"}))).data,[s]),S=i.useCallback(async(y,m,b)=>(await G(await s(`/workspaces/${y.id}/members/${m}/roles/${b}/remove`,{method:"POST"}))).data,[s]),k=i.useCallback(async y=>(await G(await s(`/organizations/${y.organization.id}/invitations`,{method:"GET"}))).data.filter(b=>String(b.workspace_id)===String(y.id)),[s]),P=i.useCallback(async(y,m,b)=>{const _=new FormData;return _.append("email",m),_.append("workspace_id",y.id),_.append("workspace_role_id",b),(await G(await s(`/organizations/${y.organization.id}/invitations`,{method:"POST",body:_}))).data},[s]),E=i.useCallback(async(y,m)=>(await G(await s(`/organizations/${y.organization.id}/invitations/${m}/discard`,{method:"POST"}))).data,[s]),z=i.useCallback(async(y,m)=>(await G(await s(`/organizations/${y.organization.id}/invitations/${m}/resend`,{method:"POST"}))).data,[s]);return{workspaces:a||[],loading:o,error:n,refetch:r,leaveWorkspace:f,createWorkspace:p,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:l,getWorkspaceRoles:u,createWorkspaceRole:g,deleteWorkspaceRole:v,inviteWorkspaceMember:x,removeWorkspaceMember:w,addWorkspaceMemberRole:$,removeWorkspaceMemberRole:S,getWorkspaceInvitations:k,createWorkspaceInvitation:P,discardWorkspaceInvitation:E,resendWorkspaceInvitation:z}},Rt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:s,updateWorkspace:a,deleteWorkspace:p,getWorkspaceMembers:f,getWorkspaceRoles:c,createWorkspaceRole:h,deleteWorkspaceRole:l,inviteWorkspaceMember:u,removeWorkspaceMember:g,addWorkspaceMemberRole:v,removeWorkspaceMemberRole:x,getWorkspaceInvitations:w,createWorkspaceInvitation:$,discardWorkspaceInvitation:S,resendWorkspaceInvitation:k}=Pt(),{workspaceMemberships:P}=Zo(),{session:E,loading:z,error:y}=Ue(),m=i.useMemo(()=>(P==null?void 0:P.find(J=>{var oe;return J.id===((oe=E==null?void 0:E.active_signin)==null?void 0:oe.active_workspace_membership_id)}))||null,[P,E]),b=i.useMemo(()=>(m==null?void 0:m.workspace)||null,[m]),_=i.useCallback(async()=>{var J;if(!(!b||!((J=E==null?void 0:E.active_signin)!=null&&J.user_id)))return await s(b.id,E.active_signin.user_id)},[b,s,E]),j=i.useCallback(async J=>{if(b)return await a(b,J)},[b,a]),T=i.useCallback(async()=>{if(b)return await p(b)},[b,p]),R=i.useCallback(async()=>b?await f(b):[],[b,f]),C=i.useCallback(async()=>b?await c(b):[],[b,c]),I=i.useCallback(async(J,oe)=>{if(b)return await h(b,J,oe)},[b,h]),M=i.useCallback(async J=>{if(b)return await l(b,J)},[b,l]),F=i.useCallback(async(J,oe)=>{if(b)return await u(b,J,oe)},[b,u]),L=i.useCallback(async J=>{if(b)return await g(b,J)},[b,g]),B=i.useCallback(async(J,oe)=>{if(b)return await v(b,J,oe)},[b,v]),O=i.useCallback(async(J,oe)=>{if(b)return await x(b,J,oe)},[b,x]),A=i.useMemo(()=>(n==null?void 0:n.find(J=>J.id===(b==null?void 0:b.id)))||null,[n,b]),X=i.useCallback(async()=>A?await w(A):[],[A,w]),te=i.useCallback(async(J,oe)=>{if(A)return await $(A,J,oe)},[A,$]),V=i.useCallback(async J=>{if(A)return await S(A,J)},[A,S]),q=i.useCallback(async J=>{if(A)return await k(A,J)},[A,k]),re=r||z,ne=o||y;return re?{activeWorkspace:null,activeMembership:null,loading:!0,error:ne,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null,getInvitations:null,createInvitation:null,discardInvitation:null,resendInvitation:null}:{activeWorkspace:b,activeMembership:m,loading:!1,error:ne,refetch:t,leave:_,updateWorkspace:j,deleteWorkspace:T,getMembers:R,getRoles:C,createRole:I,deleteRole:M,inviteMember:F,removeMember:L,addMemberRole:B,removeMemberRole:O,getInvitations:X,createInvitation:te,discardInvitation:V,resendInvitation:q}},xu=async t=>(await G(await t("/me"))).data,vu=async t=>(await G(await t("/me/signins"))).data;function sr(){const{client:t,loading:r}=Be(),{data:o,error:n,isLoading:s,mutate:a}=Fe(r?null:"/user",()=>xu(t)),p=async I=>{const M=new FormData;for(const[L,B]of Object.entries(I))B!=null&&B!==""&&M.append(L,String(B));const F=await G(await t("/me",{method:"POST",body:M}));return a(),F},f=async()=>await G(await t("/me/email-addresses",{method:"GET"})),c=async I=>await G(await t(`/me/email-addresses/${I}`,{method:"GET"})),h=async I=>{const M=new FormData;return M.append("email",I),await G(await t("/me/email-addresses",{method:"POST",body:M}))},l=async I=>await G(await t(`/me/email-addresses/${I}/delete`,{method:"POST"})),u=async I=>await G(await t(`/me/email-addresses/${I}/prepare-verification`,{method:"POST"})),g=async(I,M)=>await G(await t(`/me/email-addresses/${I}/attempt-verification?code=${M}`,{method:"POST"})),v=async(I,M)=>{const F=new FormData;return F.append("phone_number",I),F.append("country_code",M),await G(await t("/me/phone-numbers",{method:"POST",body:F}))},x=async I=>await G(await t(`/me/phone-numbers/${I}/delete`,{method:"POST"})),w=async I=>await G(await t(`/me/phone-numbers/${I}/prepare-verification`,{method:"POST"})),$=async(I,M)=>{const F=new FormData;return F.append("code",M),await G(await t(`/me/phone-numbers/${I}/attempt-verification`,{method:"POST",body:F}))},S=async I=>{const M=await G(await t(`/me/phone-numbers/${I}/make-primary`,{method:"POST"}));return a(),M},k=async I=>await G(await t(`/me/email-addresses/${I}/make-primary`,{method:"POST"})),P=async()=>(await G(await t("/me/authenticator",{method:"POST"}))).data,E=async(I,M)=>{const F=new FormData;return F.append("authenticator_id",I),M.forEach(B=>{F.append("codes",B)}),await G(await t("/me/authenticator/attempt-verification",{method:"POST",body:F}))},z=async I=>await G(await t(`/me/authenticator/${I}/delete`,{method:"POST"})),y=async()=>(await G(await t("/me/backup-codes",{method:"POST"}))).data,m=async I=>{const M=new FormData;return M.append("file",I),await G(await t("/me/profile-picture",{method:"POST",body:M}))},b=async()=>(await G(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,_=async(I,M)=>{const F=new FormData;return F.append("current_password",I),F.append("new_password",M),await G(await t("/me/update-password",{method:"POST",body:F}))},j=async I=>{const M=new FormData;M.append("current_password",I);const F=await G(await t("/me/remove-password",{method:"POST",body:M}));return a(),F},T=async I=>{const M=new FormData;return M.append("password",I),await G(await t("/me/account/delete",{method:"POST",body:M}))},R=async I=>await G(await t(`/me/social-connections/${I}/disconnect`,{method:"POST"})),C=async({provider:I,redirectUri:M})=>{var B;const F=new URLSearchParams({provider:I});M&&F.append("redirect_uri",M);const L=await G(await t(`/me/init-sso-connection?${F.toString()}`,{method:"POST"}));return"data"in L&&((B=L.data)!=null&&B.oauth_url)&&window.open(L.data.oauth_url,"_blank"),L};return{user:{...o,refetch:a},loading:r||s,error:n||null,updateProfile:p,getEmailAddresses:f,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:l,prepareEmailVerification:u,attemptEmailVerification:g,makeEmailPrimary:k,createPhoneNumber:v,deletePhoneNumber:x,preparePhoneVerification:w,attemptPhoneVerification:$,makePhonePrimary:S,setupAuthenticator:P,verifyAuthenticator:E,deleteAuthenticator:z,generateBackupCodes:y,regenerateBackupCodes:b,updateProfilePicture:m,disconnectSocialConnection:R,connectSocialAccount:C,updatePassword:_,removePassword:j,deleteAccount:T}}function bc(){const{client:t,loading:r}=Be(),{data:o,error:n,isLoading:s,mutate:a}=Fe(r?null:"/me/signins",()=>vu(t));return{signins:o,error:n||null,removeSignin:async f=>await G(await t(`/me/signins/${f}/signout`,{method:"POST"})),refetch:a,loading:s||r}}function bu(){const{session:t,loading:r}=Ue(),{loading:o,organizationMemberships:n}=Ct(),{loading:s,workspaceMemberships:a}=Zo();if(r||o||s)return{loading:!0,orgMembership:null,workspaceMembership:null};const p=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_organization_membership_id)}),[t]),f=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:a==null?void 0:a.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:p,workspaceMembership:f}}function yc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),s=async a=>{n(!0);try{const p=new FormData;for(const[h,l]of Object.entries(a))l&&p.append(h,l);const f=await t("/waitlist/join",{method:"POST",body:p});return await G(f)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:s}}function wc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),[s,a]=i.useState(null),[p,f]=i.useState(null),[c,h]=i.useState(null),[l,u]=i.useState(!1),[g,v]=i.useState(null);i.useEffect(()=>{if(l||r)return;const w=new URLSearchParams(window.location.search),$=w.get("code"),S=w.get("state"),k=w.get("error"),P=w.get("error_description");if(!$&&!k){u(!0);const E=new Error("No OAuth callback data found.");a(E);return}if(u(!0),n(!0),k){const E=P||k,z=new Error(`OAuth Error: ${E}`);a(z),n(!1);return}if($&&S)x($,S);else{const E=new Error("Missing required OAuth parameters");a(E),n(!1)}},[l,r]);const x=async(w,$)=>{try{let S,k;try{const z=$.split(".");if(z.length!==2)throw new Error("Invalid OAuth state format - missing signature");const y=z[0].replace(/-/g,"+").replace(/_/g,"/"),m=y.length%4?"=".repeat(4-y.length%4):"",_=atob(y+m).split("|")[0];if(_==="sign_in")S="/auth/oauth2/callback",k="GET";else if(_==="connect_social")S="/me/sso-connection-callback",k="POST";else throw new Error(`Unknown OAuth action: ${_}`)}catch(z){const y=z instanceof Error?z:new Error("Failed to parse OAuth state");a(new Error(`Invalid OAuth callback: ${y.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const P=await t(`${S}?code=${encodeURIComponent(w)}&state=${encodeURIComponent($)}`,{method:k}),E=await G(P);if("data"in E){const z=E.data.session,y=E.data.redirect_uri||null;if(f(z),h(y),z.signin_attempts&&z.signin_attempts.length>0){const m=z.signin_attempts.at(-1);m&&v(m)}}else{const z=new Error("SSO callback failed");a(z)}}catch(S){const k=S instanceof Error?S:new Error("Unknown error occurred");a(k)}finally{n(!1)}};return{loading:o,error:s,session:p,redirectUri:c,processed:l,signinAttempt:g}}function jc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),[s,a]=i.useState(null);return{loading:r||o,verifyMagicLink:async f=>{if(!f.token||!f.attempt)throw new Error("Invalid magic link parameters");n(!0),a(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",f.token),c.searchParams.set("attempt",f.attempt),f.redirectUri&&c.searchParams.set("redirect_uri",f.redirectUri);const h=await t(c.pathname+c.search,{method:"GET"}),l=await G(h);return n(!1),a(!0),l}catch(c){throw n(!1),a(!1),c}},success:s}}function _c(){const[t,r]=i.useState({});return i.useEffect(()=>{const o=new URLSearchParams(window.location.search);r({token:o.get("token")||void 0,attempt:o.get("attempt")||void 0,redirectUri:o.get("redirect_uri")||void 0})},[]),t}function kc(){const{client:t,loading:r}=Be();return{loading:r,forgotPassword:async a=>{const p=new FormData;p.append("email",a);const f=await t("/auth/forgot-password",{method:"POST",body:p});return await G(f)},verifyOtp:async(a,p)=>{const f=new FormData;f.append("email",a),f.append("otp",p);const c=await t("/auth/forgot-password",{method:"POST",body:f});return await G(c)},resetPassword:async(a,p)=>{const f=new FormData;f.append("token",a),f.append("password",p);const c=await t("/auth/reset-password",{method:"POST",body:f});return await G(c)}}}function Cc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:s,onError:a,reconnectDelay:p=1e3,maxReconnectAttempts:f=5}={}){const{session:c,loading:h}=Ue(),{deployment:l,loading:u}=ve(),[g,v]=i.useState(!1),[x,w]=i.useState(null),$=i.useRef(null),S=i.useRef(null),k=i.useRef(0),P=i.useRef(null),E=i.useRef(s),z=i.useRef(a),y=i.useRef(r),m=i.useRef(o),b=i.useRef(n),_=i.useRef(p),j=i.useRef(f);E.current=s,z.current=a,y.current=r,m.current=o,b.current=n,_.current=p,j.current=f;const T=i.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null),P.current&&(clearInterval(P.current),P.current=null),$.current&&($.current.close(),$.current=null)},[]),R=i.useCallback(async()=>{var B;if(!t||h||u||!c||!l)return;T();const M=new URL(l.backend_host),F=M.protocol==="https:"?"wss:":"ws:",L=new URL("/realtime/notifications",`${F}//${M.host}`);if(l.mode==="staging"){const O=localStorage.getItem("__dev_session__");O&&L.searchParams.set("__dev_session__",O)}y.current&&y.current.length>0&&y.current.forEach(O=>L.searchParams.append("channels",O)),m.current&&m.current.length>0&&m.current.forEach(O=>L.searchParams.append("organization_ids",O.toString())),b.current&&b.current.length>0&&b.current.forEach(O=>L.searchParams.append("workspace_ids",O.toString()));try{const O=new WebSocket(L.toString());$.current=O,O.onopen=()=>{v(!0),w(null),k.current=0,P.current=setInterval(()=>{O.readyState===WebSocket.OPEN&&O.send("ping")},3e4)},O.onmessage=A=>{var X,te;try{const V=JSON.parse(A.data);if(V.type==="notification"&&V.data)(X=E.current)==null||X.call(E,V.data);else if(V.type==="error"){const q=V.error||"Unknown error occurred";w(q),(te=z.current)==null||te.call(z,q)}else V.type}catch{}},O.onerror=()=>{var A;w("Connection error occurred"),(A=z.current)==null||A.call(z,"Connection error occurred")},O.onclose=A=>{var X;if(v(!1),P.current&&(clearInterval(P.current),P.current=null),t&&A.code!==1e3&&k.current<j.current){k.current++;const te=_.current*Math.pow(2,k.current-1);S.current=setTimeout(()=>{R()},te)}else k.current>=j.current&&(w("Max reconnection attempts reached"),(X=z.current)==null||X.call(z,"Max reconnection attempts reached"))}}catch{w("Failed to connect"),(B=z.current)==null||B.call(z,"Failed to connect")}},[t,h,u,c,l,T]);i.useEffect(()=>(R(),()=>{T()}),[R,T]),i.useEffect(()=>{$.current&&$.current.readyState===WebSocket.OPEN&&R()},[r,o,n,R]);const C=i.useCallback(()=>{T(),v(!1)},[T]),I=i.useCallback(()=>{k.current=0,R()},[R]);return{isConnected:g,connectionError:x,disconnect:C,reconnect:I}}async function yu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(p=>o.append("channels",p)),r.organization_ids&&r.organization_ids.forEach(p=>o.append("organization_ids",p.toString())),r.workspace_ids&&r.workspace_ids.forEach(p=>o.append("workspace_ids",p.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,s=await t(n,{method:"GET"});return(await G(s)).data}async function wu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}async function ju(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return G(o)}async function _u(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return G(r)}async function ku(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return G(o)}function Sc(t){const{client:r,loading:o}=Be(),{data:n,error:s,mutate:a,isLoading:p}=Fe(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>yu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});Cc({enabled:!o&&!!n,onNotification:i.useCallback(u=>{a(async g=>!g||g.notifications.some(x=>x.id===u.id.toString())?g:{...g,notifications:[{id:u.id.toString(),user_id:u.user_id.toString(),deployment_id:u.deployment_id.toString(),title:u.title,body:u.body,severity:u.severity,action_url:u.action_url,action_label:u.action_label,is_read:!1,is_archived:!1,created_at:u.created_at,updated_at:u.created_at},...g.notifications],unread_count:g.unread_count+1,total:g.total+1},!1)},[a]),onError:i.useCallback(()=>{},[])});const f=i.useCallback(async u=>{o||(await a(async g=>g&&{...g,notifications:g.notifications.map(v=>v.id===u?{...v,is_read:!0}:v),unread_count:Math.max(0,g.unread_count-1)},!1),await ju(r,u),await a())},[r,o,a]),c=i.useCallback(async()=>{o||(await a(async u=>u&&{...u,notifications:u.notifications.map(g=>({...g,is_read:!0})),unread_count:0},!1),await _u(r),await a())},[r,a]),h=i.useCallback(async u=>{o||(await a(async g=>{if(!g)return g;const v=g.notifications.find(x=>x.id===u);return{...g,notifications:g.notifications.filter(x=>x.id!==u),unread_count:v&&!v.is_read?Math.max(0,g.unread_count-1):g.unread_count,total:Math.max(0,g.total-1)}},!1),await ku(r,u),await a())},[r,o,a]),l=i.useCallback(async()=>{await a()},[a]);return!n||o||p?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:s,refetch:l}:{loading:!1,error:s,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:f,markAllAsRead:c,deleteNotification:h,refetch:l}}async function Cu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}function Su(){const{client:t,loading:r}=Be(),{data:o,error:n,mutate:s}=Fe(r?null:"wacht-notifications:channel-counts",()=>Cu(t),{refreshInterval:3e4,revalidateOnFocus:!0}),a=async()=>{await s()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:a}:{loading:!1,counts:o,error:n,refetch:a}}const Yt=class Yt{constructor(){tt(this,"ws",null);tt(this,"messageHandlers",new Set);tt(this,"connectionStateHandlers",new Set);tt(this,"reconnectTimer",null);tt(this,"reconnectAttempts",0);tt(this,"url",null);tt(this,"isIntentionalDisconnect",!1);tt(this,"sessionMessages",{});tt(this,"currentSessionKey",null)}static getInstance(){return Yt.instance||(Yt.instance=new Yt),Yt.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};tt(Yt,"instance");let ss=Yt;const Xe=ss.getInstance(),wt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Le={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Ot={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Ks(t){switch(t){case Ot.IDLE:return Le.IDLE;case Ot.STARTING:return Le.STARTING;case Ot.RUNNING:return Le.RUNNING;case Ot.WAITING_FOR_INPUT:return Le.WAITING_FOR_INPUT;case Ot.COMPLETED:return Le.COMPLETED;case Ot.FAILED:case Ot.CANCELLED:return Le.FAILED;default:return Le.IDLE}}function Qs(t){return t===Le.STARTING||t===Le.RUNNING||t===Le.WAITING_FOR_INPUT}function zc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:s=!0}){const{deployment:a}=ve(),{client:p}=Be(),[f,c]=i.useState([]),[h,l]=i.useState(null),[u,g]=i.useState(null),[v,x]=i.useState(!1),[w,$]=i.useState(!1),[S,k]=i.useState(Le.IDLE),[P,E]=i.useState({status:wt.DISCONNECTED}),[z,y]=i.useState(!0),[m,b]=i.useState(!1),_=i.useRef(null),j=i.useRef(null),T=i.useCallback(V=>{var q,re;switch(V.message_type){case"session_connected":if(x(!0),E({status:wt.CONNECTED}),(q=V.data)!=null&&q.execution_status){const J=V.data.execution_status,oe=Ks(J);k(oe),$(Qs(oe))}break;case"conversation_message":R(V.data);break;case"user_input_request":C(V.data);break;case"platform_event":I(V.data);break;case"platform_function":M(V.data);break;case"execution_complete":$(!1),k(Le.IDLE),j.current=null;break;case"execution_error":$(!1),k(Le.FAILED),j.current=null;break;case"execution_cancelled":$(!1),k(Le.IDLE),j.current=null;break;case"execution_status":const ne=(re=V.data)==null?void 0:re.status;if(ne){const J=Ks(ne);k(J),$(Qs(J))}break}},[h]),R=i.useCallback(V=>{var oe,de,Z,ae,xe,ue,U,pe;const{id:q,message_type:re,content:ne}=V,J=K=>f.some(H=>H.id===K);if(re==="system_decision"||re==="action_execution_result"||re==="assistant_task_breakdown"||re==="assistant_validation"||re==="assistant_action_planning"||re==="context_results"){l(null),g(null);let K="";if(re==="system_decision"){const H=ne==null?void 0:ne.step,se=ne==null?void 0:ne.reasoning;if(H==="gathercontext")se&&se.length>0?K=se.length>60?`${se.substring(0,60)}...`:se:K="Gathering context...";else if(H==="executeaction")K="Executing action";else if(H==="deliverresponse")K="Preparing response";else if(H==="taskplanning")K="Planning approach";else if(H==="validateprogress")K="Validating progress";else if(H==="acknowledge")K="Processing request";else if(H==="finishplanning")K="Finalizing plan";else if(H==="executetasks")K="Executing tasks";else if(H==="requestuserinput")K="Waiting for input";else if(H==="complete")K="Completed";else if(H==="examinetool")K="Examining tool";else if(H==="examineworkflow")K="Examining workflow";else{const me=(ne==null?void 0:ne.confidence)||.5;me>.8?K="Analyzing":me>.6?K="Thinking":K="Reasoning"}}else if(re==="action_execution_result")((oe=ne.task_execution)==null?void 0:oe.status)==="completed"?K="Task execution completed":(de=ne.task_execution)!=null&&de.approach?K=ne.task_execution.approach:K="Executing task";else if(re==="assistant_task_breakdown")(Z=ne.task_breakdown)!=null&&Z.total_tasks?K=`Identified ${ne.task_breakdown.total_tasks} tasks`:K="Planning tasks";else if(re==="assistant_validation")K="Validated results";else if(re==="assistant_action_planning")(ae=ne.task_execution)!=null&&ae.total_tasks?K=`Planned ${ne.task_execution.total_tasks} tasks`:(ue=(xe=ne.task_execution)==null?void 0:xe.tasks)!=null&&ue.length?K=`Planned ${ne.task_execution.tasks.length} tasks`:K="Planning actions";else if(re==="context_results"){const H=ne.query,se=ne.result_count||0;H&&H!=="General context gathering"?K=`${H}: Found ${se} results`:K=`Found ${se} results`}K&&!J(q)&&c(H=>[...H,{id:q,role:"system",content:K,timestamp:new Date,metadata:{type:"log",messageType:re}}]);return}if(re==="user_message")J(q)||(l(null),g(null),c(K=>[...K,{id:q,role:"user",content:ne.message,images:ne.images,timestamp:new Date}]));else if(re==="agent_response")J(q)||(l(null),g(null),$(!1),k(Le.IDLE),j.current=null,c(K=>[...K,{id:q,role:"assistant",content:ne.response,timestamp:new Date,isStreaming:!1}]));else if(re==="assistant_acknowledgment")J(q)||(l(null),g(null),c(K=>[...K,{id:q,role:"assistant",content:ne.acknowledgment_message,timestamp:new Date}]));else if(re==="assistant_ideation"||re==="assistant_action_planning"||re==="action_execution_result"||re==="assistant_validation"||re==="assistant_context_gathering"||re==="assistant_task_breakdown"){let K="";if(ne.reasoning_summary)K=ne.reasoning_summary;else if((U=ne.task_execution)!=null&&U.approach)K=ne.task_execution.approach;else if(ne.strategic_synthesis)K=ne.strategic_synthesis;else if((pe=ne.task_breakdown)!=null&&pe.total_tasks)K=`Breaking down into ${ne.task_breakdown.total_tasks} tasks...`;else if(ne.acknowledgment_message)K=ne.acknowledgment_message;else return;c(H=>[...H,{id:q,role:"assistant",content:K,timestamp:new Date}])}else if(re==="user_input_request"){const K={question:ne.question,context:ne.context,input_type:ne.input_type,options:ne.options||ne.suggestions,default_value:ne.default_value,placeholder:ne.placeholder};k("waiting_for_input"),c(H=>[...H,{id:q,role:"system",content:K.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:K}}])}},[]),C=i.useCallback(async V=>{k("waiting_for_input");const q=`input-request-${Date.now()}`;c(re=>[...re,{id:q,role:"system",content:V.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:V}}])},[]),I=i.useCallback(V=>{const{event_label:q,event_data:re}=V;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(q,re)},[n]),M=i.useCallback(async V=>{const{function_name:q,function_data:re}=V,{parameters:ne,execution_id:J}=re;if(!(n!=null&&n.onPlatformFunction)){Xe.send({message_type:{platform_function_result:[J,{error:"No platform function handler registered"}]},data:{}});return}try{const oe=await n.onPlatformFunction(q,ne,J),de={message_type:{platform_function_result:[J,oe]},data:{}};Xe.send(de)}catch(oe){Xe.send({message_type:{platform_function_result:[J,{error:oe instanceof Error?oe.message:"Function execution failed",stack:oe instanceof Error?oe.stack:void 0}]},data:{}})}},[n]);i.useEffect(()=>{if(!a)return;const q=`wss://${a==null?void 0:a.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;E({status:wt.CONNECTING}),Xe.connect(q)},[a,o]),i.useEffect(()=>Xe.onConnectionStateChange(q=>{E({status:q.isConnected?wt.CONNECTED:q.error?wt.ERROR:wt.DISCONNECTED}),x(q.isConnected)}),[]),i.useEffect(()=>Xe.onMessage(T),[T]),i.useEffect(()=>{v&&t&&r&&s&&Xe.send({message_type:{session_connect:[t,r]},data:{}})},[v,t,r,s]);const F=i.useCallback(async()=>(v&&t&&r&&Xe.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[v,t,r]),L=i.useCallback((V,q)=>{v&&(l(V),g(q||null),$(!0),k(Le.STARTING),Xe.send({message_type:{message_input:V},data:q?{images:q}:{}}))},[v]),B=i.useCallback(()=>{c([]),j.current=null},[]),O=i.useCallback(V=>{!v||S!==Le.WAITING_FOR_INPUT||(Xe.send({message_type:{user_input_response:V},data:{}}),k(Le.RUNNING))},[v,S]),A=i.useCallback(async V=>{var q;if(!(!o||!t))try{const re=new URLSearchParams({token:o,limit:"50"});V&&(re.append("before_id",V),b(!0));const J=await(await p(`/api/agent/contexts/${t}/messages?${re}`,{method:"GET"})).json();if(J.status===200&&J.data){const oe=J.data;if(Array.isArray(oe.data)){const de=oe.data.filter(Z=>{var ue;let ae=Z.content;if(typeof Z.content=="string")try{ae=JSON.parse(Z.content)}catch{ae={message:Z.content}}const xe=((ue=Z.metadata)==null?void 0:ue.message_type)||(ae==null?void 0:ae.message_type);return xe==="user_message"||xe==="agent_response"||xe==="assistant_acknowledgment"||xe==="user_input_request"||xe==="system_decision"||xe==="action_execution_result"||xe==="assistant_task_breakdown"||xe==="assistant_validation"||xe==="assistant_action_planning"||xe==="context_results"}).map(Z=>{var K,H,se,me,fe,W,N;let ae="",xe,ue,U=Z.content;if(typeof Z.content=="string")try{U=JSON.parse(Z.content)}catch{U=Z.content}const pe=((K=Z.metadata)==null?void 0:K.message_type)||(U==null?void 0:U.message_type);if(pe==="user_message"?(ae=(U==null?void 0:U.message)||"",xe=(U==null?void 0:U.images)||void 0):pe==="agent_response"?ae=(U==null?void 0:U.response)||"":pe==="assistant_acknowledgment"?ae=(U==null?void 0:U.acknowledgment_message)||"":pe==="user_input_request"&&(ae=(U==null?void 0:U.question)||"",ue={type:"user_input_request",userInputRequest:{question:(U==null?void 0:U.question)||"",context:(U==null?void 0:U.context)||"",input_type:(U==null?void 0:U.input_type)||"text",options:(U==null?void 0:U.options)||(U==null?void 0:U.suggestions)||[],default_value:(U==null?void 0:U.default_value)||"",placeholder:(U==null?void 0:U.placeholder)||""}}),pe==="system_decision"||pe==="action_execution_result"||pe==="assistant_task_breakdown"||pe==="assistant_validation"||pe==="assistant_action_planning"||pe==="context_results"){let D="";if(pe==="system_decision"){const Y=U==null?void 0:U.step,ie=U==null?void 0:U.reasoning;if(Y==="gathercontext")ie&&ie.length>0?D=ie.length>60?`${ie.substring(0,60)}...`:ie:D="Gathering context...";else if(Y==="executeaction")D="Executing action";else if(Y==="deliverresponse")D="Preparing response";else if(Y==="taskplanning")D="Planning approach";else if(Y==="validateprogress")D="Validating progress";else if(Y==="acknowledge")D="Processing request";else if(Y==="finishplanning")D="Finalizing plan";else if(Y==="executetasks")D="Executing tasks";else if(Y==="requestuserinput")D="Waiting for input";else if(Y==="complete")D="Completed";else if(Y==="examinetool")D="Examining tool";else if(Y==="examineworkflow")D="Examining workflow";else{const ee=(U==null?void 0:U.confidence)||.5;ee>.8?D="Analyzing":ee>.6?D="Thinking":D="Reasoning"}}else if(pe==="action_execution_result")((H=U==null?void 0:U.task_execution)==null?void 0:H.status)==="completed"?D="Task execution completed":(se=U==null?void 0:U.task_execution)!=null&&se.approach?D=U.task_execution.approach:D="Executing task";else if(pe==="assistant_task_breakdown")(me=U==null?void 0:U.task_breakdown)!=null&&me.total_tasks?D=`Identified ${U.task_breakdown.total_tasks} tasks`:D="Planning tasks";else if(pe==="assistant_validation")D="Validated results";else if(pe==="assistant_action_planning")(fe=U==null?void 0:U.task_execution)!=null&&fe.total_tasks?D=`Planned ${U.task_execution.total_tasks} tasks`:(N=(W=U==null?void 0:U.task_execution)==null?void 0:W.tasks)!=null&&N.length?D=`Planned ${U.task_execution.tasks.length} tasks`:D="Planning actions";else if(pe==="context_results"){const Y=U==null?void 0:U.query,ie=(U==null?void 0:U.result_count)||0;Y&&Y!=="General context gathering"?D=`${Y}: Found ${ie} results`:D=`Found ${ie} results`}ae=D,ue={type:"log",messageType:pe}}return{id:Z.id,role:pe==="user_message"?"user":pe==="user_input_request"?"system":"assistant",content:ae,images:xe,timestamp:new Date(Z.timestamp||Z.created_at||Date.now()),metadata:ue}}).filter(Z=>Z.content||Z.metadata||Z.images).sort((Z,ae)=>{const xe=BigInt(Z.id),ue=BigInt(ae.id);return xe<ue?-1:xe>ue?1:0});de.length>0&&(_.current=de[0].id),V?(c(Z=>[...de,...Z]),y(de.length>=50)):(c(de),de.length>0&&((q=de[de.length-1].metadata)==null?void 0:q.type)==="user_input_request"&&k(Le.WAITING_FOR_INPUT)),b(!1)}}}catch(re){console.error("Failed to fetch messages:",re),b(!1)}},[o,t,p]);i.useEffect(()=>{t&&o&&A()},[t,o]);const X=i.useCallback(async()=>{if(!(m||!z||!_.current)){b(!0);try{await A(_.current)}finally{b(!1)}}},[m,z,A]),te=i.useCallback(()=>{!v||!w||(Xe.send({message_type:{cancel_execution:null},data:{}}),$(!1),k("idle"))},[v,w]);return{messages:f,pendingMessage:h,pendingImages:u,connectionState:P,isConnected:v,isExecuting:w,executionStatus:S,isWaitingForInput:S==="waiting_for_input",hasMoreMessages:z,isLoadingMore:m,sendMessage:L,submitUserInput:O,clearMessages:B,loadMoreMessages:X,cancelExecution:te,connect:F,disconnect:()=>Xe.disconnect()}}const $c=()=>{const{client:t}=Be(),[r,o]=i.useState(!1),[n,s]=i.useState(null),[a,p]=i.useState(null),f=i.useCallback(async h=>{o(!0),s(null),p(null);try{const l=new FormData;l.append("token",h);const u=await t("/organizations/invitations/accept",{method:"POST",body:l}),v=(await G(u)).data;return p(v),v.error_code&&s(v.message||"Failed to accept invitation"),v}catch(l){const u=l.message||"Failed to accept invitation";s(u);const g={error_code:"NETWORK_ERROR",message:u};return p(g),g}finally{o(!1)}},[t]),c=i.useCallback(()=>{s(null),p(null)},[]);return{acceptInvitation:f,invitationData:a,loading:r,error:n,reset:c}},zu=({children:t})=>{const{loading:r}=ve();return r?null:e.jsx(e.Fragment,{children:t})},$u=({children:t})=>{const{loading:r}=ve();return r?e.jsx(e.Fragment,{children:t}):null};var Ye=function(){return Ye=Object.assign||function(r){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(r[a]=o[a])}return r},Ye.apply(this,arguments)};function tr(t,r,o){if(o||arguments.length===2)for(var n=0,s=r.length,a;n<s;n++)(a||!(n in r))&&(a||(a=Array.prototype.slice.call(r,0,n)),a[n]=r[n]);return t.concat(a||Array.prototype.slice.call(r))}function Eu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var Iu=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Pu=Eu(function(t){return Iu.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ie="-ms-",Nr="-moz-",$e="-webkit-",Ec="comm",Ko="rule",js="decl",Ru="@import",Ic="@keyframes",Tu="@layer",Pc=Math.abs,_s=String.fromCharCode,as=Object.assign;function Mu(t,r){return We(t,0)^45?(((r<<2^We(t,0))<<2^We(t,1))<<2^We(t,2))<<2^We(t,3):0}function Rc(t){return t.trim()}function yt(t,r){return(t=r.exec(t))?t[0]:t}function ye(t,r,o){return t.replace(r,o)}function Io(t,r,o){return t.indexOf(r,o)}function We(t,r){return t.charCodeAt(r)|0}function yr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function Tc(t){return t.length}function Lr(t,r){return r.push(t),t}function Ou(t,r){return t.map(r).join("")}function Xs(t,r){return t.filter(function(o){return!yt(o,r)})}var Qo=1,wr=1,Mc=0,Je=0,De=0,Sr="";function Xo(t,r,o,n,s,a,p,f){return{value:t,root:r,parent:o,type:n,props:s,children:a,line:Qo,column:wr,length:p,return:"",siblings:f}}function zt(t,r){return as(Xo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function lr(t){for(;t.root;)t=zt(t.root,{children:[t]});Lr(t,t.siblings)}function Au(){return De}function Lu(){return De=Je>0?We(Sr,--Je):0,wr--,De===10&&(wr=1,Qo--),De}function rt(){return De=Je<Mc?We(Sr,Je++):0,wr++,De===10&&(wr=1,Qo++),De}function Kt(){return We(Sr,Je)}function Po(){return Je}function Jo(t,r){return yr(Sr,t,r)}function is(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Du(t){return Qo=wr=1,Mc=ct(Sr=t),Je=0,[]}function Nu(t){return Sr="",t}function xn(t){return Rc(Jo(Je-1,cs(t===91?t+2:t===40?t+1:t)))}function Fu(t){for(;(De=Kt())&&De<33;)rt();return is(t)>2||is(De)>3?"":" "}function Bu(t,r){for(;--r&&rt()&&!(De<48||De>102||De>57&&De<65||De>70&&De<97););return Jo(t,Po()+(r<6&&Kt()==32&&rt()==32))}function cs(t){for(;rt();)switch(De){case t:return Je;case 34:case 39:t!==34&&t!==39&&cs(De);break;case 40:t===41&&cs(t);break;case 92:rt();break}return Je}function Uu(t,r){for(;rt()&&t+De!==57;)if(t+De===84&&Kt()===47)break;return"/*"+Jo(r,Je-1)+"*"+_s(t===47?t:rt())}function Wu(t){for(;!is(Kt());)rt();return Jo(t,Je)}function Vu(t){return Nu(Ro("",null,null,null,[""],t=Du(t),0,[0],t))}function Ro(t,r,o,n,s,a,p,f,c){for(var h=0,l=0,u=p,g=0,v=0,x=0,w=1,$=1,S=1,k=0,P="",E=s,z=a,y=n,m=P;$;)switch(x=k,k=rt()){case 40:if(x!=108&&We(m,u-1)==58){Io(m+=ye(xn(k),"&","&\f"),"&\f",Pc(h?f[h-1]:0))!=-1&&(S=-1);break}case 34:case 39:case 91:m+=xn(k);break;case 9:case 10:case 13:case 32:m+=Fu(x);break;case 92:m+=Bu(Po()-1,7);continue;case 47:switch(Kt()){case 42:case 47:Lr(Gu(Uu(rt(),Po()),r,o,c),c);break;default:m+="/"}break;case 123*w:f[h++]=ct(m)*S;case 125*w:case 59:case 0:switch(k){case 0:case 125:$=0;case 59+l:S==-1&&(m=ye(m,/\f/g,"")),v>0&&ct(m)-u&&Lr(v>32?ea(m+";",n,o,u-1,c):ea(ye(m," ","")+";",n,o,u-2,c),c);break;case 59:m+=";";default:if(Lr(y=Js(m,r,o,h,l,s,f,P,E=[],z=[],u,a),a),k===123)if(l===0)Ro(m,r,y,y,E,a,u,f,z);else switch(g===99&&We(m,3)===110?100:g){case 100:case 108:case 109:case 115:Ro(t,y,y,n&&Lr(Js(t,y,y,0,0,s,f,P,s,E=[],u,z),z),s,z,u,f,n?E:z);break;default:Ro(m,y,y,y,[""],z,0,f,z)}}h=l=v=0,w=S=1,P=m="",u=p;break;case 58:u=1+ct(m),v=x;default:if(w<1){if(k==123)--w;else if(k==125&&w++==0&&Lu()==125)continue}switch(m+=_s(k),k*w){case 38:S=l>0?1:(m+="\f",-1);break;case 44:f[h++]=(ct(m)-1)*S,S=1;break;case 64:Kt()===45&&(m+=xn(rt())),g=Kt(),l=u=ct(P=m+=Wu(Po())),k++;break;case 45:x===45&&ct(m)==2&&(w=0)}}return a}function Js(t,r,o,n,s,a,p,f,c,h,l,u){for(var g=s-1,v=s===0?a:[""],x=Tc(v),w=0,$=0,S=0;w<n;++w)for(var k=0,P=yr(t,g+1,g=Pc($=p[w])),E=t;k<x;++k)(E=Rc($>0?v[k]+" "+P:ye(P,/&\f/g,v[k])))&&(c[S++]=E);return Xo(t,r,o,s===0?Ko:f,c,h,l,u)}function Gu(t,r,o,n){return Xo(t,r,o,Ec,_s(Au()),yr(t,2,-2),0,n)}function ea(t,r,o,n,s){return Xo(t,r,o,js,yr(t,0,n),yr(t,n+1,-1),n,s)}function Oc(t,r,o){switch(Mu(t,r)){case 5103:return $e+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return $e+t+t;case 4789:return Nr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return $e+t+Nr+t+Ie+t+t;case 5936:switch(We(t,r+11)){case 114:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return $e+t+Ie+t+t;case 6165:return $e+t+Ie+"flex-"+t+t;case 5187:return $e+t+ye(t,/(\w+).+(:[^]+)/,$e+"box-$1$2"+Ie+"flex-$1$2")+t;case 5443:return $e+t+Ie+"flex-item-"+ye(t,/flex-|-self/g,"")+(yt(t,/flex-|baseline/)?"":Ie+"grid-row-"+ye(t,/flex-|-self/g,""))+t;case 4675:return $e+t+Ie+"flex-line-pack"+ye(t,/align-content|flex-|-self/g,"")+t;case 5548:return $e+t+Ie+ye(t,"shrink","negative")+t;case 5292:return $e+t+Ie+ye(t,"basis","preferred-size")+t;case 6060:return $e+"box-"+ye(t,"-grow","")+$e+t+Ie+ye(t,"grow","positive")+t;case 4554:return $e+ye(t,/([^-])(transform)/g,"$1"+$e+"$2")+t;case 6187:return ye(ye(ye(t,/(zoom-|grab)/,$e+"$1"),/(image-set)/,$e+"$1"),t,"")+t;case 5495:case 3959:return ye(t,/(image-set\([^]*)/,$e+"$1$`$1");case 4968:return ye(ye(t,/(.+:)(flex-)?(.*)/,$e+"box-pack:$3"+Ie+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+$e+t+t;case 4200:if(!yt(t,/flex-|baseline/))return Ie+"grid-column-align"+yr(t,r)+t;break;case 2592:case 3360:return Ie+ye(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,s){return r=s,yt(n.props,/grid-\w+-end/)})?~Io(t+(o=o[r].value),"span",0)?t:Ie+ye(t,"-start","")+t+Ie+"grid-row-span:"+(~Io(o,"span",0)?yt(o,/\d+/):+yt(o,/\d+/)-+yt(t,/\d+/))+";":Ie+ye(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return yt(n.props,/grid-\w+-start/)})?t:Ie+ye(ye(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ye(t,/(.+)-inline(.+)/,$e+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ct(t)-1-r>6)switch(We(t,r+1)){case 109:if(We(t,r+4)!==45)break;case 102:return ye(t,/(.+:)(.+)-([^]+)/,"$1"+$e+"$2-$3$1"+Nr+(We(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~Io(t,"stretch",0)?Oc(ye(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ye(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,a,p,f,c,h){return Ie+s+":"+a+h+(p?Ie+s+"-span:"+(f?c:+c-+a)+h:"")+t});case 4949:if(We(t,r+6)===121)return ye(t,":",":"+$e)+t;break;case 6444:switch(We(t,We(t,14)===45?18:11)){case 120:return ye(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+$e+(We(t,14)===45?"inline-":"")+"box$3$1"+$e+"$2$3$1"+Ie+"$2box$3")+t;case 100:return ye(t,":",":"+Ie)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ye(t,"scroll-","scroll-snap-")+t}return t}function Do(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Hu(t,r,o,n){switch(t.type){case Tu:if(t.children.length)break;case Ru:case js:return t.return=t.return||t.value;case Ec:return"";case Ic:return t.return=t.value+"{"+Do(t.children,n)+"}";case Ko:if(!ct(t.value=t.props.join(",")))return""}return ct(o=Do(t.children,n))?t.return=t.value+"{"+o+"}":""}function qu(t){var r=Tc(t);return function(o,n,s,a){for(var p="",f=0;f<r;f++)p+=t[f](o,n,s,a)||"";return p}}function Yu(t){return function(r){r.root||(r=r.return)&&t(r)}}function Zu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case js:t.return=Oc(t.value,t.length,o);return;case Ic:return Do([zt(t,{value:ye(t.value,"@","@"+$e)})],n);case Ko:if(t.length)return Ou(o=t.props,function(s){switch(yt(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":lr(zt(t,{props:[ye(s,/:(read-\w+)/,":"+Nr+"$1")]})),lr(zt(t,{props:[s]})),as(t,{props:Xs(o,n)});break;case"::placeholder":lr(zt(t,{props:[ye(s,/:(plac\w+)/,":"+$e+"input-$1")]})),lr(zt(t,{props:[ye(s,/:(plac\w+)/,":"+Nr+"$1")]})),lr(zt(t,{props:[ye(s,/:(plac\w+)/,Ie+"input-$1")]})),lr(zt(t,{props:[s]})),as(t,{props:Xs(o,n)});break}return""})}}var Ku={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},rr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Ac="active",Lc="data-styled-version",en="6.1.19",ks=`/*!sc*/
19
+ `,No=typeof window<"u"&&typeof document<"u",Qu=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==""?process.env.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&process.env.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.SC_DISABLE_SPEEDY!==void 0&&process.env.SC_DISABLE_SPEEDY!==""?process.env.SC_DISABLE_SPEEDY!=="false"&&process.env.SC_DISABLE_SPEEDY:process.env.NODE_ENV!=="production"),ta=/invalid hook call/i,Jr=new Set,Xu=function(t,r){if(process.env.NODE_ENV!=="production"){var o=r?' with the id of "'.concat(r,'"'):"",n="The component ".concat(t).concat(o,` has been created dynamically.
20
20
  `)+`You may see this warning because you've called styled inside another component.
21
21
  To resolve this only create new StyledComponents outside of any render method and function component.
22
22
  See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
23
- `,s=console.error;try{var i=!0;console.error=function(u){for(var f=[],c=1;c<arguments.length;c++)f[c-1]=arguments[c];ti.test(u)?(i=!1,Jr.delete(n)):s.apply(void 0,tr([u],f,!1))},a.useRef(),i&&!Jr.has(n)&&(console.warn(n),Jr.add(n))}catch(u){ti.test(u.message)&&Jr.delete(n)}finally{console.error=s}}},tn=Object.freeze([]),jr=Object.freeze({});function Ju(t,r,o){return o===void 0&&(o=jr),t.theme!==o.theme&&t.theme||r||o.theme}var ls=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),ep=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,tp=/(^-|-$)/g;function ri(t){return t.replace(ep,"-").replace(tp,"")}var rp=/(a)(d)/gi,eo=52,oi=function(t){return String.fromCharCode(t+(t>25?39:97))};function ds(t){var r,o="";for(r=Math.abs(t);r>eo;r=r/eo|0)o=oi(r%eo)+o;return(oi(r%eo)+o).replace(rp,"$1-$2")}var vn,Dc=5381,qt=function(t,r){for(var o=r.length;o;)t=33*t^r.charCodeAt(--o);return t},Nc=function(t){return qt(Dc,t)};function Fc(t){return ds(Nc(t)>>>0)}function Bc(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function bn(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var Uc=typeof Symbol=="function"&&Symbol.for,Wc=Uc?Symbol.for("react.memo"):60115,op=Uc?Symbol.for("react.forward_ref"):60112,np={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},sp={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Vc={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},ip=((vn={})[op]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},vn[Wc]=Vc,vn);function ni(t){return("type"in(r=t)&&r.type.$$typeof)===Wc?Vc:"$$typeof"in t?ip[t.$$typeof]:np;var r}var ap=Object.defineProperty,cp=Object.getOwnPropertyNames,si=Object.getOwnPropertySymbols,lp=Object.getOwnPropertyDescriptor,dp=Object.getPrototypeOf,ii=Object.prototype;function Gc(t,r,o){if(typeof r!="string"){if(ii){var n=dp(r);n&&n!==ii&&Gc(t,n,o)}var s=cp(r);si&&(s=s.concat(si(r)));for(var i=ni(t),u=ni(r),f=0;f<s.length;++f){var c=s[f];if(!(c in sp||o&&o[c]||u&&c in u||i&&c in i)){var h=lp(r,c);try{ap(t,c,h)}catch{}}}}return t}function _r(t){return typeof t=="function"}function Cs(t){return typeof t=="object"&&"styledComponentId"in t}function Zt(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function us(t,r){if(t.length===0)return"";for(var o=t[0],n=1;n<t.length;n++)o+=t[n];return o}function kr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function ps(t,r,o){if(o===void 0&&(o=!1),!o&&!kr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var n=0;n<r.length;n++)t[n]=ps(t[n],r[n]);else if(kr(r))for(var n in r)t[n]=ps(t[n],r[n]);return t}function Ss(t,r){Object.defineProperty(t,"toString",{value:r})}var up=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
23
+ `,s=console.error;try{var a=!0;console.error=function(p){for(var f=[],c=1;c<arguments.length;c++)f[c-1]=arguments[c];ta.test(p)?(a=!1,Jr.delete(n)):s.apply(void 0,tr([p],f,!1))},i.useRef(),a&&!Jr.has(n)&&(console.warn(n),Jr.add(n))}catch(p){ta.test(p.message)&&Jr.delete(n)}finally{console.error=s}}},tn=Object.freeze([]),jr=Object.freeze({});function Ju(t,r,o){return o===void 0&&(o=jr),t.theme!==o.theme&&t.theme||r||o.theme}var ls=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),ep=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,tp=/(^-|-$)/g;function ra(t){return t.replace(ep,"-").replace(tp,"")}var rp=/(a)(d)/gi,eo=52,oa=function(t){return String.fromCharCode(t+(t>25?39:97))};function ds(t){var r,o="";for(r=Math.abs(t);r>eo;r=r/eo|0)o=oa(r%eo)+o;return(oa(r%eo)+o).replace(rp,"$1-$2")}var vn,Dc=5381,qt=function(t,r){for(var o=r.length;o;)t=33*t^r.charCodeAt(--o);return t},Nc=function(t){return qt(Dc,t)};function Fc(t){return ds(Nc(t)>>>0)}function Bc(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function bn(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var Uc=typeof Symbol=="function"&&Symbol.for,Wc=Uc?Symbol.for("react.memo"):60115,op=Uc?Symbol.for("react.forward_ref"):60112,np={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},sp={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Vc={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},ap=((vn={})[op]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},vn[Wc]=Vc,vn);function na(t){return("type"in(r=t)&&r.type.$$typeof)===Wc?Vc:"$$typeof"in t?ap[t.$$typeof]:np;var r}var ip=Object.defineProperty,cp=Object.getOwnPropertyNames,sa=Object.getOwnPropertySymbols,lp=Object.getOwnPropertyDescriptor,dp=Object.getPrototypeOf,aa=Object.prototype;function Gc(t,r,o){if(typeof r!="string"){if(aa){var n=dp(r);n&&n!==aa&&Gc(t,n,o)}var s=cp(r);sa&&(s=s.concat(sa(r)));for(var a=na(t),p=na(r),f=0;f<s.length;++f){var c=s[f];if(!(c in sp||o&&o[c]||p&&c in p||a&&c in a)){var h=lp(r,c);try{ip(t,c,h)}catch{}}}}return t}function _r(t){return typeof t=="function"}function Cs(t){return typeof t=="object"&&"styledComponentId"in t}function Zt(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function us(t,r){if(t.length===0)return"";for(var o=t[0],n=1;n<t.length;n++)o+=t[n];return o}function kr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function ps(t,r,o){if(o===void 0&&(o=!1),!o&&!kr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var n=0;n<r.length;n++)t[n]=ps(t[n],r[n]);else if(kr(r))for(var n in r)t[n]=ps(t[n],r[n]);return t}function Ss(t,r){Object.defineProperty(t,"toString",{value:r})}var up=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
24
24
 
25
25
  `,2:`Can't collect styles once you've consumed a \`ServerStyleSheet\`'s styles! \`ServerStyleSheet\` is a one off instance for each server-side render cycle.
26
26
 
@@ -61,7 +61,7 @@ as for instance in your render method then you may be running into this limitati
61
61
 
62
62
  `,17:`CSSStyleSheet could not be found on HTMLStyleElement.
63
63
  Has styled-components' style tag been unmounted or altered by another script?
64
- `,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function pp(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],s=1,i=t.length;s<i;s+=1)n.push(t[s]);return n.forEach(function(u){o=o.replace(/%[a-z]/,u)}),o}function zr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(pp.apply(void 0,tr([up[t]],r,!1)).trim())}var hp=function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r}return t.prototype.indexOfGroup=function(r){for(var o=0,n=0;n<r;n++)o+=this.groupSizes[n];return o},t.prototype.insertRules=function(r,o){if(r>=this.groupSizes.length){for(var n=this.groupSizes,s=n.length,i=s;r>=i;)if((i<<=1)<0)throw zr(16,"".concat(r));this.groupSizes=new Uint32Array(i),this.groupSizes.set(n),this.length=i;for(var u=s;u<i;u++)this.groupSizes[u]=0}for(var f=this.indexOfGroup(r+1),c=(u=0,o.length);u<c;u++)this.tag.insertRule(f,o[u])&&(this.groupSizes[r]++,f++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),s=n+o;this.groupSizes[r]=0;for(var i=n;i<s;i++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],s=this.indexOfGroup(r),i=s+n,u=s;u<i;u++)o+="".concat(this.tag.getRule(u)).concat(ks);return o},t}(),fp=1<<30,To=new Map,Fo=new Map,Mo=1,to=function(t){if(To.has(t))return To.get(t);for(;Fo.has(Mo);)Mo++;var r=Mo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>fp))throw zr(16,"".concat(r));return To.set(t,r),Fo.set(r,t),r},gp=function(t,r){Mo=r+1,To.set(t,r),Fo.set(r,t)},mp="style[".concat(rr,"][").concat(Lc,'="').concat(en,'"]'),xp=new RegExp("^".concat(rr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),vp=function(t,r,o){for(var n,s=o.split(","),i=0,u=s.length;i<u;i++)(n=s[i])&&t.registerName(r,n)},bp=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(ks),s=[],i=0,u=n.length;i<u;i++){var f=n[i].trim();if(f){var c=f.match(xp);if(c){var h=0|parseInt(c[1],10),l=c[2];h!==0&&(gp(l,h),vp(t,l,c[3]),t.getTag().insertRules(h,s)),s.length=0}else s.push(f)}}},ai=function(t){for(var r=document.querySelectorAll(mp),o=0,n=r.length;o<n;o++){var s=r[o];s&&s.getAttribute(rr)!==Ac&&(bp(t,s),s.parentNode&&s.parentNode.removeChild(s))}};function yp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var Hc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),s=function(f){var c=Array.from(f.querySelectorAll("style[".concat(rr,"]")));return c[c.length-1]}(o),i=s!==void 0?s.nextSibling:null;n.setAttribute(rr,Ac),n.setAttribute(Lc,en);var u=yp();return u&&n.setAttribute("nonce",u),o.insertBefore(n,i),n},wp=function(){function t(r){this.element=Hc(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,s=0,i=n.length;s<i;s++){var u=n[s];if(u.ownerNode===o)return u}throw zr(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),jp=function(){function t(r){this.element=Hc(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,o){if(r<=this.length&&r>=0){var n=document.createTextNode(o);return this.element.insertBefore(n,this.nodes[r]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(r){this.element.removeChild(this.nodes[r]),this.length--},t.prototype.getRule=function(r){return r<this.length?this.nodes[r].textContent:""},t}(),_p=function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,o){return r<=this.length&&(this.rules.splice(r,0,o),this.length++,!0)},t.prototype.deleteRule=function(r){this.rules.splice(r,1),this.length--},t.prototype.getRule=function(r){return r<this.length?this.rules[r]:""},t}(),ci=No,kp={isServer:!No,useCSSOMInjection:!Qu},qc=function(){function t(r,o,n){r===void 0&&(r=jr),o===void 0&&(o={});var s=this;this.options=Ye(Ye({},kp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&No&&ci&&(ci=!1,ai(this)),Ss(this,function(){return function(i){for(var u=i.getTag(),f=u.length,c="",h=function(p){var g=function(z){return Fo.get(z)}(p);if(g===void 0)return"continue";var x=i.names.get(g),m=u.getGroup(p);if(x===void 0||!x.size||m.length===0)return"continue";var b="".concat(rr,".g").concat(p,'[id="').concat(g,'"]'),$="";x!==void 0&&x.forEach(function(z){z.length>0&&($+="".concat(z,","))}),c+="".concat(m).concat(b,'{content:"').concat($,'"}').concat(ks)},l=0;l<f;l++)h(l);return c}(s)})}return t.registerId=function(r){return to(r)},t.prototype.rehydrate=function(){!this.server&&No&&ai(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(Ye(Ye({},this.options),r),this.gs,o&&this.names||void 0)},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=function(o){var n=o.useCSSOMInjection,s=o.target;return o.isServer?new _p(s):n?new wp(s):new jp(s)}(this.options),new hp(r)));var r},t.prototype.hasNameForId=function(r,o){return this.names.has(r)&&this.names.get(r).has(o)},t.prototype.registerName=function(r,o){if(to(r),this.names.has(r))this.names.get(r).add(o);else{var n=new Set;n.add(o),this.names.set(r,n)}},t.prototype.insertRules=function(r,o,n){this.registerName(r,o),this.getTag().insertRules(to(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(to(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),Cp=/&/g,Sp=/^\s*\/\/.*$/gm;function Yc(t,r){return t.map(function(o){return o.type==="rule"&&(o.value="".concat(r," ").concat(o.value),o.value=o.value.replaceAll(",",",".concat(r," ")),o.props=o.props.map(function(n){return"".concat(r," ").concat(n)})),Array.isArray(o.children)&&o.type!=="@keyframes"&&(o.children=Yc(o.children,r)),o})}function zp(t){var r,o,n,s=jr,i=s.options,u=i===void 0?jr:i,f=s.plugins,c=f===void 0?tn:f,h=function(g,x,m){return m.startsWith(o)&&m.endsWith(o)&&m.replaceAll(o,"").length>0?".".concat(r):g},l=c.slice();l.push(function(g){g.type===Ko&&g.value.includes("&")&&(g.props[0]=g.props[0].replace(Cp,o).replace(n,h))}),u.prefix&&l.push(Zu),l.push(Hu);var p=function(g,x,m,b){x===void 0&&(x=""),m===void 0&&(m=""),b===void 0&&(b="&"),r=b,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var $=g.replace(Sp,""),z=Vu(m||x?"".concat(m," ").concat(x," { ").concat($," }"):$);u.namespace&&(z=Yc(z,u.namespace));var w=[];return Do(z,qu(l.concat(Yu(function(y){return w.push(y)})))),w};return p.hash=c.length?c.reduce(function(g,x){return x.name||zr(15),qt(g,x.name)},Dc).toString():"",p}var $p=new qc,hs=zp(),Zc=a.createContext({shouldForwardProp:void 0,styleSheet:$p,stylis:hs});Zc.Consumer;a.createContext(void 0);function li(){return a.useContext(Zc)}var fs=function(){function t(r,o){var n=this;this.inject=function(s,i){i===void 0&&(i=hs);var u=n.name+i.hash;s.hasNameForId(n.id,u)||s.insertRules(n.id,u,i(n.rules,u,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,Ss(this,function(){throw zr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=hs),this.name+r.hash},t}(),Ep=function(t){return t>="A"&&t<="Z"};function di(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;Ep(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Kc=function(t){return t==null||t===!1||t===""},Qc=function(t){var r,o,n=[];for(var s in t){var i=t[s];t.hasOwnProperty(s)&&!Kc(i)&&(Array.isArray(i)&&i.isCss||_r(i)?n.push("".concat(di(s),":"),i,";"):kr(i)?n.push.apply(n,tr(tr(["".concat(s," {")],Qc(i),!1),["}"],!1)):n.push("".concat(di(s),": ").concat((r=s,(o=i)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Ku||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Qt(t,r,o,n){if(Kc(t))return[];if(Cs(t))return[".".concat(t.styledComponentId)];if(_r(t)){if(!_r(i=t)||i.prototype&&i.prototype.isReactComponent||!r)return[t];var s=t(r);return process.env.NODE_ENV==="production"||typeof s!="object"||Array.isArray(s)||s instanceof fs||kr(s)||s===null||console.error("".concat(Bc(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Qt(s,r,o,n)}var i;return t instanceof fs?o?(t.inject(o,n),[t.getName(n)]):[t]:kr(t)?Qc(t):Array.isArray(t)?Array.prototype.concat.apply(tn,t.map(function(u){return Qt(u,r,o,n)})):[t.toString()]}function Ip(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(_r(o)&&!Cs(o))return!1}return!0}var Pp=Nc(en),Rp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&Ip(r),this.componentId=o,this.baseHash=qt(Pp,o),this.baseStyle=n,qc.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var s=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))s=Zt(s,this.staticRulesId);else{var i=us(Qt(this.rules,r,o,n)),u=ds(qt(this.baseHash,i)>>>0);if(!o.hasNameForId(this.componentId,u)){var f=n(i,".".concat(u),void 0,this.componentId);o.insertRules(this.componentId,u,f)}s=Zt(s,u),this.staticRulesId=u}else{for(var c=qt(this.baseHash,n.hash),h="",l=0;l<this.rules.length;l++){var p=this.rules[l];if(typeof p=="string")h+=p,process.env.NODE_ENV!=="production"&&(c=qt(c,p));else if(p){var g=us(Qt(p,r,o,n));c=qt(c,g+l),h+=g}}if(h){var x=ds(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(h,".".concat(x),void 0,this.componentId)),s=Zt(s,x)}}return s},t}(),Xc=a.createContext(void 0);Xc.Consumer;var yn={},ui=new Set;function Tp(t,r,o){var n=Cs(t),s=t,i=!bn(t),u=r.attrs,f=u===void 0?tn:u,c=r.componentId,h=c===void 0?function(k,C){var _=typeof k!="string"?"sc":ri(k);yn[_]=(yn[_]||0)+1;var v="".concat(_,"-").concat(Fc(en+_+yn[_]));return C?"".concat(C,"-").concat(v):v}(r.displayName,r.parentComponentId):c,l=r.displayName,p=l===void 0?function(k){return bn(k)?"styled.".concat(k):"Styled(".concat(Bc(k),")")}(t):l,g=r.displayName&&r.componentId?"".concat(ri(r.displayName),"-").concat(r.componentId):r.componentId||h,x=n&&s.attrs?s.attrs.concat(f).filter(Boolean):f,m=r.shouldForwardProp;if(n&&s.shouldForwardProp){var b=s.shouldForwardProp;if(r.shouldForwardProp){var $=r.shouldForwardProp;m=function(k,C){return b(k,C)&&$(k,C)}}else m=b}var z=new Rp(o,g,n?s.componentStyle:void 0);function w(k,C){return function(_,v,P){var I=_.attrs,S=_.componentStyle,T=_.defaultProps,E=_.foldedComponentIds,j=_.styledComponentId,R=_.target,M=a.useContext(Xc),F=li(),A=_.shouldForwardProp||F.shouldForwardProp;process.env.NODE_ENV!=="production"&&a.useDebugValue(j);var B=Ju(v,M,T)||jr,O=function(te,re,le){for(var oe,de=Ye(Ye({},re),{className:void 0,theme:le}),Z=0;Z<te.length;Z+=1){var se=_r(oe=te[Z])?oe(de):oe;for(var xe in se)de[xe]=xe==="className"?Zt(de[xe],se[xe]):xe==="style"?Ye(Ye({},de[xe]),se[xe]):se[xe]}return re.className&&(de.className=Zt(de.className,re.className)),de}(I,v,B),L=O.as||R,X={};for(var ee in O)O[ee]===void 0||ee[0]==="$"||ee==="as"||ee==="theme"&&O.theme===B||(ee==="forwardedAs"?X.as=O.forwardedAs:A&&!A(ee,L)||(X[ee]=O[ee],A||process.env.NODE_ENV!=="development"||Pu(ee)||ui.has(ee)||!ls.has(L)||(ui.add(ee),console.warn('styled-components: it looks like an unknown prop "'.concat(ee,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var V=function(te,re){var le=li(),oe=te.generateAndInjectStyles(re,le.styleSheet,le.stylis);return process.env.NODE_ENV!=="production"&&a.useDebugValue(oe),oe}(S,O);process.env.NODE_ENV!=="production"&&_.warnTooManyClasses&&_.warnTooManyClasses(V);var q=Zt(E,j);return V&&(q+=" "+V),O.className&&(q+=" "+O.className),X[bn(L)&&!ls.has(L)?"class":"className"]=q,P&&(X.ref=P),a.createElement(L,X)}(y,k,C)}w.displayName=p;var y=a.forwardRef(w);return y.attrs=x,y.componentStyle=z,y.displayName=p,y.shouldForwardProp=m,y.foldedComponentIds=n?Zt(s.foldedComponentIds,s.styledComponentId):"",y.styledComponentId=g,y.target=n?s.target:t,Object.defineProperty(y,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(k){this._foldedDefaultProps=n?function(C){for(var _=[],v=1;v<arguments.length;v++)_[v-1]=arguments[v];for(var P=0,I=_;P<I.length;P++)ps(C,I[P],!0);return C}({},s.defaultProps,k):k}}),process.env.NODE_ENV!=="production"&&(Xu(p,g),y.warnTooManyClasses=function(k,C){var _={},v=!1;return function(P){if(!v&&(_[P]=!0,Object.keys(_).length>=200)){var I=C?' with the id of "'.concat(C,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(k).concat(I,`.
64
+ `,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function pp(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],s=1,a=t.length;s<a;s+=1)n.push(t[s]);return n.forEach(function(p){o=o.replace(/%[a-z]/,p)}),o}function zr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(pp.apply(void 0,tr([up[t]],r,!1)).trim())}var hp=function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r}return t.prototype.indexOfGroup=function(r){for(var o=0,n=0;n<r;n++)o+=this.groupSizes[n];return o},t.prototype.insertRules=function(r,o){if(r>=this.groupSizes.length){for(var n=this.groupSizes,s=n.length,a=s;r>=a;)if((a<<=1)<0)throw zr(16,"".concat(r));this.groupSizes=new Uint32Array(a),this.groupSizes.set(n),this.length=a;for(var p=s;p<a;p++)this.groupSizes[p]=0}for(var f=this.indexOfGroup(r+1),c=(p=0,o.length);p<c;p++)this.tag.insertRule(f,o[p])&&(this.groupSizes[r]++,f++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),s=n+o;this.groupSizes[r]=0;for(var a=n;a<s;a++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],s=this.indexOfGroup(r),a=s+n,p=s;p<a;p++)o+="".concat(this.tag.getRule(p)).concat(ks);return o},t}(),fp=1<<30,To=new Map,Fo=new Map,Mo=1,to=function(t){if(To.has(t))return To.get(t);for(;Fo.has(Mo);)Mo++;var r=Mo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>fp))throw zr(16,"".concat(r));return To.set(t,r),Fo.set(r,t),r},gp=function(t,r){Mo=r+1,To.set(t,r),Fo.set(r,t)},mp="style[".concat(rr,"][").concat(Lc,'="').concat(en,'"]'),xp=new RegExp("^".concat(rr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),vp=function(t,r,o){for(var n,s=o.split(","),a=0,p=s.length;a<p;a++)(n=s[a])&&t.registerName(r,n)},bp=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(ks),s=[],a=0,p=n.length;a<p;a++){var f=n[a].trim();if(f){var c=f.match(xp);if(c){var h=0|parseInt(c[1],10),l=c[2];h!==0&&(gp(l,h),vp(t,l,c[3]),t.getTag().insertRules(h,s)),s.length=0}else s.push(f)}}},ia=function(t){for(var r=document.querySelectorAll(mp),o=0,n=r.length;o<n;o++){var s=r[o];s&&s.getAttribute(rr)!==Ac&&(bp(t,s),s.parentNode&&s.parentNode.removeChild(s))}};function yp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var Hc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),s=function(f){var c=Array.from(f.querySelectorAll("style[".concat(rr,"]")));return c[c.length-1]}(o),a=s!==void 0?s.nextSibling:null;n.setAttribute(rr,Ac),n.setAttribute(Lc,en);var p=yp();return p&&n.setAttribute("nonce",p),o.insertBefore(n,a),n},wp=function(){function t(r){this.element=Hc(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,s=0,a=n.length;s<a;s++){var p=n[s];if(p.ownerNode===o)return p}throw zr(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),jp=function(){function t(r){this.element=Hc(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,o){if(r<=this.length&&r>=0){var n=document.createTextNode(o);return this.element.insertBefore(n,this.nodes[r]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(r){this.element.removeChild(this.nodes[r]),this.length--},t.prototype.getRule=function(r){return r<this.length?this.nodes[r].textContent:""},t}(),_p=function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,o){return r<=this.length&&(this.rules.splice(r,0,o),this.length++,!0)},t.prototype.deleteRule=function(r){this.rules.splice(r,1),this.length--},t.prototype.getRule=function(r){return r<this.length?this.rules[r]:""},t}(),ca=No,kp={isServer:!No,useCSSOMInjection:!Qu},qc=function(){function t(r,o,n){r===void 0&&(r=jr),o===void 0&&(o={});var s=this;this.options=Ye(Ye({},kp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&No&&ca&&(ca=!1,ia(this)),Ss(this,function(){return function(a){for(var p=a.getTag(),f=p.length,c="",h=function(u){var g=function(S){return Fo.get(S)}(u);if(g===void 0)return"continue";var v=a.names.get(g),x=p.getGroup(u);if(v===void 0||!v.size||x.length===0)return"continue";var w="".concat(rr,".g").concat(u,'[id="').concat(g,'"]'),$="";v!==void 0&&v.forEach(function(S){S.length>0&&($+="".concat(S,","))}),c+="".concat(x).concat(w,'{content:"').concat($,'"}').concat(ks)},l=0;l<f;l++)h(l);return c}(s)})}return t.registerId=function(r){return to(r)},t.prototype.rehydrate=function(){!this.server&&No&&ia(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(Ye(Ye({},this.options),r),this.gs,o&&this.names||void 0)},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=function(o){var n=o.useCSSOMInjection,s=o.target;return o.isServer?new _p(s):n?new wp(s):new jp(s)}(this.options),new hp(r)));var r},t.prototype.hasNameForId=function(r,o){return this.names.has(r)&&this.names.get(r).has(o)},t.prototype.registerName=function(r,o){if(to(r),this.names.has(r))this.names.get(r).add(o);else{var n=new Set;n.add(o),this.names.set(r,n)}},t.prototype.insertRules=function(r,o,n){this.registerName(r,o),this.getTag().insertRules(to(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(to(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),Cp=/&/g,Sp=/^\s*\/\/.*$/gm;function Yc(t,r){return t.map(function(o){return o.type==="rule"&&(o.value="".concat(r," ").concat(o.value),o.value=o.value.replaceAll(",",",".concat(r," ")),o.props=o.props.map(function(n){return"".concat(r," ").concat(n)})),Array.isArray(o.children)&&o.type!=="@keyframes"&&(o.children=Yc(o.children,r)),o})}function zp(t){var r,o,n,s=jr,a=s.options,p=a===void 0?jr:a,f=s.plugins,c=f===void 0?tn:f,h=function(g,v,x){return x.startsWith(o)&&x.endsWith(o)&&x.replaceAll(o,"").length>0?".".concat(r):g},l=c.slice();l.push(function(g){g.type===Ko&&g.value.includes("&")&&(g.props[0]=g.props[0].replace(Cp,o).replace(n,h))}),p.prefix&&l.push(Zu),l.push(Hu);var u=function(g,v,x,w){v===void 0&&(v=""),x===void 0&&(x=""),w===void 0&&(w="&"),r=w,o=v,n=new RegExp("\\".concat(o,"\\b"),"g");var $=g.replace(Sp,""),S=Vu(x||v?"".concat(x," ").concat(v," { ").concat($," }"):$);p.namespace&&(S=Yc(S,p.namespace));var k=[];return Do(S,qu(l.concat(Yu(function(P){return k.push(P)})))),k};return u.hash=c.length?c.reduce(function(g,v){return v.name||zr(15),qt(g,v.name)},Dc).toString():"",u}var $p=new qc,hs=zp(),Zc=i.createContext({shouldForwardProp:void 0,styleSheet:$p,stylis:hs});Zc.Consumer;i.createContext(void 0);function la(){return i.useContext(Zc)}var fs=function(){function t(r,o){var n=this;this.inject=function(s,a){a===void 0&&(a=hs);var p=n.name+a.hash;s.hasNameForId(n.id,p)||s.insertRules(n.id,p,a(n.rules,p,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,Ss(this,function(){throw zr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=hs),this.name+r.hash},t}(),Ep=function(t){return t>="A"&&t<="Z"};function da(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;Ep(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Kc=function(t){return t==null||t===!1||t===""},Qc=function(t){var r,o,n=[];for(var s in t){var a=t[s];t.hasOwnProperty(s)&&!Kc(a)&&(Array.isArray(a)&&a.isCss||_r(a)?n.push("".concat(da(s),":"),a,";"):kr(a)?n.push.apply(n,tr(tr(["".concat(s," {")],Qc(a),!1),["}"],!1)):n.push("".concat(da(s),": ").concat((r=s,(o=a)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Ku||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Qt(t,r,o,n){if(Kc(t))return[];if(Cs(t))return[".".concat(t.styledComponentId)];if(_r(t)){if(!_r(a=t)||a.prototype&&a.prototype.isReactComponent||!r)return[t];var s=t(r);return process.env.NODE_ENV==="production"||typeof s!="object"||Array.isArray(s)||s instanceof fs||kr(s)||s===null||console.error("".concat(Bc(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Qt(s,r,o,n)}var a;return t instanceof fs?o?(t.inject(o,n),[t.getName(n)]):[t]:kr(t)?Qc(t):Array.isArray(t)?Array.prototype.concat.apply(tn,t.map(function(p){return Qt(p,r,o,n)})):[t.toString()]}function Ip(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(_r(o)&&!Cs(o))return!1}return!0}var Pp=Nc(en),Rp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&Ip(r),this.componentId=o,this.baseHash=qt(Pp,o),this.baseStyle=n,qc.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var s=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))s=Zt(s,this.staticRulesId);else{var a=us(Qt(this.rules,r,o,n)),p=ds(qt(this.baseHash,a)>>>0);if(!o.hasNameForId(this.componentId,p)){var f=n(a,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,f)}s=Zt(s,p),this.staticRulesId=p}else{for(var c=qt(this.baseHash,n.hash),h="",l=0;l<this.rules.length;l++){var u=this.rules[l];if(typeof u=="string")h+=u,process.env.NODE_ENV!=="production"&&(c=qt(c,u));else if(u){var g=us(Qt(u,r,o,n));c=qt(c,g+l),h+=g}}if(h){var v=ds(c>>>0);o.hasNameForId(this.componentId,v)||o.insertRules(this.componentId,v,n(h,".".concat(v),void 0,this.componentId)),s=Zt(s,v)}}return s},t}(),Xc=i.createContext(void 0);Xc.Consumer;var yn={},ua=new Set;function Tp(t,r,o){var n=Cs(t),s=t,a=!bn(t),p=r.attrs,f=p===void 0?tn:p,c=r.componentId,h=c===void 0?function(E,z){var y=typeof E!="string"?"sc":ra(E);yn[y]=(yn[y]||0)+1;var m="".concat(y,"-").concat(Fc(en+y+yn[y]));return z?"".concat(z,"-").concat(m):m}(r.displayName,r.parentComponentId):c,l=r.displayName,u=l===void 0?function(E){return bn(E)?"styled.".concat(E):"Styled(".concat(Bc(E),")")}(t):l,g=r.displayName&&r.componentId?"".concat(ra(r.displayName),"-").concat(r.componentId):r.componentId||h,v=n&&s.attrs?s.attrs.concat(f).filter(Boolean):f,x=r.shouldForwardProp;if(n&&s.shouldForwardProp){var w=s.shouldForwardProp;if(r.shouldForwardProp){var $=r.shouldForwardProp;x=function(E,z){return w(E,z)&&$(E,z)}}else x=w}var S=new Rp(o,g,n?s.componentStyle:void 0);function k(E,z){return function(y,m,b){var _=y.attrs,j=y.componentStyle,T=y.defaultProps,R=y.foldedComponentIds,C=y.styledComponentId,I=y.target,M=i.useContext(Xc),F=la(),L=y.shouldForwardProp||F.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(C);var B=Ju(m,M,T)||jr,O=function(re,ne,J){for(var oe,de=Ye(Ye({},ne),{className:void 0,theme:J}),Z=0;Z<re.length;Z+=1){var ae=_r(oe=re[Z])?oe(de):oe;for(var xe in ae)de[xe]=xe==="className"?Zt(de[xe],ae[xe]):xe==="style"?Ye(Ye({},de[xe]),ae[xe]):ae[xe]}return ne.className&&(de.className=Zt(de.className,ne.className)),de}(_,m,B),A=O.as||I,X={};for(var te in O)O[te]===void 0||te[0]==="$"||te==="as"||te==="theme"&&O.theme===B||(te==="forwardedAs"?X.as=O.forwardedAs:L&&!L(te,A)||(X[te]=O[te],L||process.env.NODE_ENV!=="development"||Pu(te)||ua.has(te)||!ls.has(A)||(ua.add(te),console.warn('styled-components: it looks like an unknown prop "'.concat(te,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var V=function(re,ne){var J=la(),oe=re.generateAndInjectStyles(ne,J.styleSheet,J.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(oe),oe}(j,O);process.env.NODE_ENV!=="production"&&y.warnTooManyClasses&&y.warnTooManyClasses(V);var q=Zt(R,C);return V&&(q+=" "+V),O.className&&(q+=" "+O.className),X[bn(A)&&!ls.has(A)?"class":"className"]=q,b&&(X.ref=b),i.createElement(A,X)}(P,E,z)}k.displayName=u;var P=i.forwardRef(k);return P.attrs=v,P.componentStyle=S,P.displayName=u,P.shouldForwardProp=x,P.foldedComponentIds=n?Zt(s.foldedComponentIds,s.styledComponentId):"",P.styledComponentId=g,P.target=n?s.target:t,Object.defineProperty(P,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(E){this._foldedDefaultProps=n?function(z){for(var y=[],m=1;m<arguments.length;m++)y[m-1]=arguments[m];for(var b=0,_=y;b<_.length;b++)ps(z,_[b],!0);return z}({},s.defaultProps,E):E}}),process.env.NODE_ENV!=="production"&&(Xu(u,g),P.warnTooManyClasses=function(E,z){var y={},m=!1;return function(b){if(!m&&(y[b]=!0,Object.keys(y).length>=200)){var _=z?' with the id of "'.concat(z,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(E).concat(_,`.
65
65
  `)+`Consider using the attrs method, together with a style object for frequently changed styles.
66
66
  Example:
67
67
  const Component = styled.div.attrs(props => ({
@@ -70,7 +70,7 @@ Example:
70
70
  },
71
71
  }))\`width: 100%;\`
72
72
 
73
- <Component />`),v=!0,_={}}}}(p,g)),Ss(y,function(){return".".concat(y.styledComponentId)}),i&&Gc(y,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),y}function pi(t,r){for(var o=[t[0]],n=0,s=r.length;n<s;n+=1)o.push(r[n],t[n+1]);return o}var hi=function(t){return Object.assign(t,{isCss:!0})};function Xt(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(_r(t)||kr(t))return hi(Qt(pi(tn,tr([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?Qt(n):hi(Qt(pi(n,r)))}function gs(t,r,o){if(o===void 0&&(o=jr),!r)throw zr(1,r);var n=function(s){for(var i=[],u=1;u<arguments.length;u++)i[u-1]=arguments[u];return t(r,o,Xt.apply(void 0,tr([s],i,!1)))};return n.attrs=function(s){return gs(t,r,Ye(Ye({},o),{attrs:Array.prototype.concat(o.attrs,s).filter(Boolean)}))},n.withConfig=function(s){return gs(t,r,Ye(Ye({},o),s))},n}var Jc=function(t){return gs(Tp,t)},d=Jc;ls.forEach(function(t){d[t]=Jc(t)});function ir(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var n=us(Xt.apply(void 0,tr([t],r,!1))),s=Fc(n);return new fs(s,n)}process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn(`It looks like you've imported 'styled-components' on React Native.
73
+ <Component />`),m=!0,y={}}}}(u,g)),Ss(P,function(){return".".concat(P.styledComponentId)}),a&&Gc(P,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),P}function pa(t,r){for(var o=[t[0]],n=0,s=r.length;n<s;n+=1)o.push(r[n],t[n+1]);return o}var ha=function(t){return Object.assign(t,{isCss:!0})};function Xt(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(_r(t)||kr(t))return ha(Qt(pa(tn,tr([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?Qt(n):ha(Qt(pa(n,r)))}function gs(t,r,o){if(o===void 0&&(o=jr),!r)throw zr(1,r);var n=function(s){for(var a=[],p=1;p<arguments.length;p++)a[p-1]=arguments[p];return t(r,o,Xt.apply(void 0,tr([s],a,!1)))};return n.attrs=function(s){return gs(t,r,Ye(Ye({},o),{attrs:Array.prototype.concat(o.attrs,s).filter(Boolean)}))},n.withConfig=function(s){return gs(t,r,Ye(Ye({},o),s))},n}var Jc=function(t){return gs(Tp,t)},d=Jc;ls.forEach(function(t){d[t]=Jc(t)});function ar(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var n=us(Xt.apply(void 0,tr([t],r,!1))),s=Fc(n);return new fs(s,n)}process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn(`It looks like you've imported 'styled-components' on React Native.
74
74
  Perhaps you're looking to import 'styled-components/native'?
75
75
  Read more about this at https://www.styled-components.com/docs/basics#react-native`);var ro="__sc-".concat(rr,"__");process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[ro]||(window[ro]=0),window[ro]===1&&console.warn(`It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.
76
76
 
@@ -89,12 +89,12 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
89
89
  *
90
90
  * This source code is licensed under the ISC license.
91
91
  * See the LICENSE file in the root directory of this source tree.
92
- */const Ap=a.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:s="",children:i,iconNode:u,...f},c)=>a.createElement("svg",{ref:c,...Op,width:r,height:r,stroke:t,strokeWidth:n?Number(o)*24/Number(r):o,className:el("lucide",s),...f},[...u.map(([h,l])=>a.createElement(h,l)),...Array.isArray(i)?i:[i]]));/**
92
+ */const Ap=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:p,...f},c)=>i.createElement("svg",{ref:c,...Op,width:r,height:r,stroke:t,strokeWidth:n?Number(o)*24/Number(r):o,className:el("lucide",s),...f},[...p.map(([h,l])=>i.createElement(h,l)),...Array.isArray(a)?a:[a]]));/**
93
93
  * @license lucide-react v0.474.0 - ISC
94
94
  *
95
95
  * This source code is licensed under the ISC license.
96
96
  * See the LICENSE file in the root directory of this source tree.
97
- */const we=(t,r)=>{const o=a.forwardRef(({className:n,...s},i)=>a.createElement(Ap,{ref:i,iconNode:r,className:el(`lucide-${Mp(t)}`,n),...s}));return o.displayName=`${t}`,o};/**
97
+ */const we=(t,r)=>{const o=i.forwardRef(({className:n,...s},a)=>i.createElement(Ap,{ref:a,iconNode:r,className:el(`lucide-${Mp(t)}`,n),...s}));return o.displayName=`${t}`,o};/**
98
98
  * @license lucide-react v0.474.0 - ISC
99
99
  *
100
100
  * This source code is licensed under the ISC license.
@@ -184,12 +184,12 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
184
184
  *
185
185
  * This source code is licensed under the ISC license.
186
186
  * See the LICENSE file in the root directory of this source tree.
187
- */const ih=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_n=we("Eye",ih);/**
187
+ */const ah=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_n=we("Eye",ah);/**
188
188
  * @license lucide-react v0.474.0 - ISC
189
189
  *
190
190
  * This source code is licensed under the ISC license.
191
191
  * See the LICENSE file in the root directory of this source tree.
192
- */const ah=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ch=we("Globe",ah);/**
192
+ */const ih=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ch=we("Globe",ih);/**
193
193
  * @license lucide-react v0.474.0 - ISC
194
194
  *
195
195
  * This source code is licensed under the ISC license.
@@ -204,7 +204,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
204
204
  *
205
205
  * This source code is licensed under the ISC license.
206
206
  * See the LICENSE file in the root directory of this source tree.
207
- */const ph=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],It=we("LogOut",ph);/**
207
+ */const ph=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],Et=we("LogOut",ph);/**
208
208
  * @license lucide-react v0.474.0 - ISC
209
209
  *
210
210
  * This source code is licensed under the ISC license.
@@ -219,7 +219,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
219
219
  *
220
220
  * This source code is licensed under the ISC license.
221
221
  * See the LICENSE file in the root directory of this source tree.
222
- */const mh=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],fi=we("MessageCircle",mh);/**
222
+ */const mh=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],fa=we("MessageCircle",mh);/**
223
223
  * @license lucide-react v0.474.0 - ISC
224
224
  *
225
225
  * This source code is licensed under the ISC license.
@@ -507,7 +507,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
507
507
  font-size: var(--font-xs);
508
508
  display: block;
509
509
  text-align: center;
510
- `;function Tt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:s=!1}){const[i,u]=a.useState(new Array(t).fill("")),[f,c]=a.useState(60),[h,l]=a.useState(!1),p=a.useRef([]),g=a.useCallback(()=>{const z=setInterval(()=>{c(w=>w<=1?(l(!0),clearInterval(z),0):w-1)},1e3);return z},[]);a.useEffect(()=>{const z=g();return()=>clearInterval(z)},[g]);const x=async()=>{var z;!h||s||!o||(await o(),l(!1),c(60),u(new Array(t).fill("")),(z=p.current[0])==null||z.focus(),g())},m=(z,w)=>{var _;if(s)return;const y=z.value,k=[...i];k[w]=y.replace(/[^0-9]/g,""),u(k);const C=k.join("");C.length===t&&r(C),y&&w<t-1&&((_=p.current[w+1])==null||_.focus())},b=(z,w)=>{var y;s||z.key==="Backspace"&&!i[w]&&w>0&&((y=p.current[w-1])==null||y.focus())},$=(z,w)=>{var v,P,I;if(s)return;z.preventDefault();const k=z.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(k.length===0)return;const C=[...i];for(let S=0;S<k.length&&w+S<t;S++)C[w+S]=k[S];if(w===0&&k.length===t)for(let S=0;S<t;S++)C[S]=k[S];u(C);const _=C.join("");if(_.length===t)r(_),(v=p.current[t-1])==null||v.focus();else{const S=C.findIndex((T,E)=>E>=w&&!T);if(S!==-1)(P=p.current[S])==null||P.focus();else{const T=C.map((E,j)=>E?j:-1).filter(E=>E!==-1).pop();T!==void 0&&T<t-1&&((I=p.current[T+1])==null||I.focus())}}};return e.jsxs(Lh,{children:[e.jsx(Dh,{children:i.map((z,w)=>e.jsx(Nh,{type:"text",maxLength:1,value:z,onChange:y=>m(y.target,w),onKeyDown:y=>b(y,w),onPaste:y=>$(y,w),ref:y=>{p.current[w]=y},disabled:s,autoFocus:w===0},w))}),n&&e.jsx(Fh,{children:n}),o&&e.jsx("div",{children:h?e.jsx(Bh,{type:"button",onClick:x,disabled:s,children:"Didn't receive a code? Resend"}):e.jsxs(Uh,{children:["Resend code in ",f,"s"]})})]})}const rl=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...t,children:[e.jsx("title",{id:"githubIconTitle",children:"GitHub"}),e.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),ol=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),e.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),e.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),nl=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),e.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),e.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),e.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),sl=t=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...t,children:e.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),Wh=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),il=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:e.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),al=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),Vh=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),cl=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),e.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),kn={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(nl,{})},microsoft_oauth:{shortLabel:"Microsoft",fullLabel:"Continue with Microsoft",icon:e.jsx(ol,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(rl,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(sl,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(Wh,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(il,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(al,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(Vh,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(cl,{})}},Gh=d.div`
510
+ `;function Tt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:s=!1}){const[a,p]=i.useState(new Array(t).fill("")),[f,c]=i.useState(60),[h,l]=i.useState(!1),u=i.useRef([]),g=i.useCallback(()=>{const S=setInterval(()=>{c(k=>k<=1?(l(!0),clearInterval(S),0):k-1)},1e3);return S},[]);i.useEffect(()=>{const S=g();return()=>clearInterval(S)},[g]);const v=async()=>{var S;!h||s||!o||(await o(),l(!1),c(60),p(new Array(t).fill("")),(S=u.current[0])==null||S.focus(),g())},x=(S,k)=>{var y;if(s)return;const P=S.value,E=[...a];E[k]=P.replace(/[^0-9]/g,""),p(E);const z=E.join("");z.length===t&&r(z),P&&k<t-1&&((y=u.current[k+1])==null||y.focus())},w=(S,k)=>{var P;s||S.key==="Backspace"&&!a[k]&&k>0&&((P=u.current[k-1])==null||P.focus())},$=(S,k)=>{var m,b,_;if(s)return;S.preventDefault();const E=S.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(E.length===0)return;const z=[...a];for(let j=0;j<E.length&&k+j<t;j++)z[k+j]=E[j];if(k===0&&E.length===t)for(let j=0;j<t;j++)z[j]=E[j];p(z);const y=z.join("");if(y.length===t)r(y),(m=u.current[t-1])==null||m.focus();else{const j=z.findIndex((T,R)=>R>=k&&!T);if(j!==-1)(b=u.current[j])==null||b.focus();else{const T=z.map((R,C)=>R?C:-1).filter(R=>R!==-1).pop();T!==void 0&&T<t-1&&((_=u.current[T+1])==null||_.focus())}}};return e.jsxs(Lh,{children:[e.jsx(Dh,{children:a.map((S,k)=>e.jsx(Nh,{type:"text",maxLength:1,value:S,onChange:P=>x(P.target,k),onKeyDown:P=>w(P,k),onPaste:P=>$(P,k),ref:P=>{u.current[k]=P},disabled:s,autoFocus:k===0},k))}),n&&e.jsx(Fh,{children:n}),o&&e.jsx("div",{children:h?e.jsx(Bh,{type:"button",onClick:v,disabled:s,children:"Didn't receive a code? Resend"}):e.jsxs(Uh,{children:["Resend code in ",f,"s"]})})]})}const rl=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...t,children:[e.jsx("title",{id:"githubIconTitle",children:"GitHub"}),e.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),ol=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),e.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),e.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),nl=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),e.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),e.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),e.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),sl=t=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...t,children:e.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),Wh=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),al=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:e.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),il=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),Vh=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),cl=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),e.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),kn={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(nl,{})},microsoft_oauth:{shortLabel:"Microsoft",fullLabel:"Continue with Microsoft",icon:e.jsx(ol,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(rl,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(sl,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(Wh,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(al,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(il,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(Vh,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(cl,{})}},Gh=d.div`
511
511
  display: flex;
512
512
  flex-direction: column;
513
513
  gap: var(--space-xs);
@@ -551,7 +551,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
551
551
  height: 16px;
552
552
  flex-shrink: 0;
553
553
  }
554
- `,Es=({connections:t,callback:r})=>{const o=()=>t.length<=6?[t]:t.length<=12?[t.slice(0,4),t.slice(4)]:[t.slice(0,4),t.slice(4,8),t.slice(8)],n=t.length,s=o();return e.jsx(Gh,{children:s.map((i,u)=>e.jsx(Hh,{children:i.map((f,c)=>{const h=f.provider;return e.jsxs(qh,{onClick:()=>r(f),type:"button",$isWide:s.length>1&&u<s.length-1,$totalProviders:n,children:[kn[h].icon,n<3&&e.jsx("span",{children:n===1?kn[h].fullLabel:kn[h].shortLabel})]},`${f.provider}-${c}`)})},`row-${u}`))})},ot=({to:t,replace:r,children:o,...n})=>{const{navigate:s}=Ge(),i=a.useCallback(u=>{u.preventDefault(),s(t,{replace:r})},[t,r,s]);return e.jsx("a",{href:t,onClick:i,...n,children:o})},Yh={sm:"36rem"},ce=d.input`
554
+ `,Es=({connections:t,callback:r})=>{const o=()=>t.length<=6?[t]:t.length<=12?[t.slice(0,4),t.slice(4)]:[t.slice(0,4),t.slice(4,8),t.slice(8)],n=t.length,s=o();return e.jsx(Gh,{children:s.map((a,p)=>e.jsx(Hh,{children:a.map((f,c)=>{const h=f.provider;return e.jsxs(qh,{onClick:()=>r(f),type:"button",$isWide:s.length>1&&p<s.length-1,$totalProviders:n,children:[kn[h].icon,n<3&&e.jsx("span",{children:n===1?kn[h].fullLabel:kn[h].shortLabel})]},`${f.provider}-${c}`)})},`row-${p}`))})},ot=({to:t,replace:r,children:o,...n})=>{const{navigate:s}=Ge(),a=i.useCallback(p=>{p.preventDefault(),s(t,{replace:r})},[t,r,s]);return e.jsx("a",{href:t,onClick:a,...n,children:o})},Yh={sm:"36rem"},le=d.input`
555
555
  padding: var(--space-sm) var(--space-md);
556
556
  width: 100%;
557
557
  height: 36px;
@@ -711,9 +711,9 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
711
711
  font-size: 0.8125rem;
712
712
  gap: 0.375rem;
713
713
  }
714
- `,rf=d(ce)`
714
+ `,rf=d(le)`
715
715
  flex: 1;
716
- `,qr=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:s})=>{const[i,u]=a.useState(!1),[f,c]=a.useState(Oo.find(m=>m.code===n)||Oo[0]),h=a.useRef(null),[l,p]=a.useState(""),g=a.useRef(null);a.useEffect(()=>{function m(b){h.current&&!h.current.contains(b.target)&&u(!1)}return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]);const x=Oo.filter(m=>m.name.toLowerCase().includes(l.toLowerCase())||m.dialCode.includes(l));return a.useEffect(()=>{s(f.dialCode)},[f,s]),e.jsxs(Zh,{children:[e.jsxs(Kh,{ref:h,children:[e.jsxs(Qh,{type:"button",onClick:()=>u(m=>!m),children:[e.jsx("span",{children:f.flag}),e.jsx("span",{children:f.dialCode})]}),e.jsxs(Xh,{$isOpen:i,children:[e.jsx(Jh,{type:"text",placeholder:"Search country...",value:l,onChange:m=>p(m.target.value),onClick:m=>m.stopPropagation()}),e.jsx(ef,{children:x.map(m=>e.jsxs(tf,{onClick:b=>{var $;b.stopPropagation(),b.preventDefault(),c(m),u(!1),($=g.current)==null||$.focus()},children:[e.jsx("span",{children:m.flag}),e.jsx("span",{children:m.name}),e.jsx("span",{className:"country-code",children:m.dialCode})]},m.code))})]})]}),e.jsx(rf,{style:{height:"100%"},type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:g,value:t,onChange:r,placeholder:"Phone number","aria-invalid":!!o,pattern:"^\\d{7,15}$"})]})},of=d.div`
716
+ `,qr=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:s})=>{const[a,p]=i.useState(!1),[f,c]=i.useState(Oo.find(x=>x.code===n)||Oo[0]),h=i.useRef(null),[l,u]=i.useState(""),g=i.useRef(null);i.useEffect(()=>{function x(w){h.current&&!h.current.contains(w.target)&&p(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const v=Oo.filter(x=>x.name.toLowerCase().includes(l.toLowerCase())||x.dialCode.includes(l));return i.useEffect(()=>{s(f.dialCode)},[f,s]),e.jsxs(Zh,{children:[e.jsxs(Kh,{ref:h,children:[e.jsxs(Qh,{type:"button",onClick:()=>p(x=>!x),children:[e.jsx("span",{children:f.flag}),e.jsx("span",{children:f.dialCode})]}),e.jsxs(Xh,{$isOpen:a,children:[e.jsx(Jh,{type:"text",placeholder:"Search country...",value:l,onChange:x=>u(x.target.value),onClick:x=>x.stopPropagation()}),e.jsx(ef,{children:v.map(x=>e.jsxs(tf,{onClick:w=>{var $;w.stopPropagation(),w.preventDefault(),c(x),p(!1),($=g.current)==null||$.focus()},children:[e.jsx("span",{children:x.flag}),e.jsx("span",{children:x.name}),e.jsx("span",{className:"country-code",children:x.dialCode})]},x.code))})]})]}),e.jsx(rf,{style:{height:"100%"},type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:g,value:t,onChange:r,placeholder:"Phone number","aria-invalid":!!o,pattern:"^\\d{7,15}$"})]})},of=d.div`
717
717
  display: flex;
718
718
  justify-content: center;
719
719
  margin-bottom: var(--space-lg);
@@ -736,7 +736,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
736
736
  width: auto;
737
737
  height: auto;
738
738
  object-fit: contain;
739
- `;function Pe(){var s;const{deployment:t}=ve(),[r,o]=a.useState(!1),n=(s=t==null?void 0:t.ui_settings)==null?void 0:s.logo_image_url;return!n||r?null:e.jsx(of,{children:e.jsx(nf,{children:e.jsx(sf,{src:n,alt:"Logo",onError:()=>o(!0)})})})}const af=ir`
739
+ `;function Pe(){var s;const{deployment:t}=ve(),[r,o]=i.useState(!1),n=(s=t==null?void 0:t.ui_settings)==null?void 0:s.logo_image_url;return!n||r?null:e.jsx(of,{children:e.jsx(nf,{children:e.jsx(sf,{src:n,alt:"Logo",onError:()=>o(!0)})})})}const af=ar`
740
740
  from {
741
741
  transform: rotate(0deg);
742
742
  }
@@ -756,7 +756,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
756
756
  padding: var(--space-lg);
757
757
  border-radius: 0;
758
758
  }
759
- `,gi=d.div`
759
+ `,ga=d.div`
760
760
  display: flex;
761
761
  justify-content: center;
762
762
  align-items: center;
@@ -784,7 +784,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
784
784
  @media (max-width: ${pt.sm}) {
785
785
  font-size: var(--font-md);
786
786
  }
787
- `,mi=d.p`
787
+ `,ma=d.p`
788
788
  color: var(--color-secondary-text);
789
789
  font-size: var(--font-xs);
790
790
  margin: 0;
@@ -816,7 +816,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
816
816
  padding: 0 var(--space-sm);
817
817
  color: var(--color-secondary-text);
818
818
  font-size: var(--font-xs);
819
- `,xi=d.form`
819
+ `,xa=d.form`
820
820
  display: flex;
821
821
  flex-direction: column;
822
822
  gap: var(--space-lg);
@@ -853,7 +853,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
853
853
  color: var(--color-error);
854
854
  margin: 0;
855
855
  margin-top: var(--space-2xs);
856
- `,vi=d.button`
856
+ `,va=d.button`
857
857
  width: 100%;
858
858
  padding: 0.5625rem 1rem;
859
859
  background: var(--color-primary);
@@ -879,7 +879,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
879
879
  padding: 0.5rem 0.875rem;
880
880
  font-size: 0.8125rem;
881
881
  }
882
- `,bi=d.div`
882
+ `,ba=d.div`
883
883
  margin-top: var(--space-lg);
884
884
  text-align: center;
885
885
  font-size: var(--font-xs);
@@ -921,7 +921,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
921
921
  `,pr=d.span`
922
922
  color: var(--color-danger);
923
923
  margin-left: 2px;
924
- `;function xf(){var V,q,te,re,le,oe,de,Z,se,xe,ue,U,pe,K,H,ne,me;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=vc(),{signIn:s}=Br("oauth"),{deployment:i}=ve(),{navigate:u}=Ge(),{session:f,refetch:c,loading:h}=Ue(),[l,p]=a.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[g,x]=a.useState({}),[m,b]=a.useState(!1),[$,z]=a.useState(void 0),[w,y]=a.useState(null),[k,C]=a.useState(null),[_,v]=a.useState(!1),P=((V=i==null?void 0:i.restrictions)==null?void 0:V.sign_up_mode)==="restricted",I=((q=i==null?void 0:i.restrictions)==null?void 0:q.sign_up_mode)==="waitlist",S=((re=(te=i==null?void 0:i.auth_settings)==null?void 0:te.multi_session_support)==null?void 0:re.enabled)??!1;a.useEffect(()=>{var fe;if(!h&&(f!=null&&f.active_signin)&&!S&&!_){v(!0);let W=new URLSearchParams(window.location.search).get("redirect_uri");W||(W=((fe=i==null?void 0:i.ui_settings)==null?void 0:fe.after_signin_redirect_url)||null),!W&&(i!=null&&i.frontend_host)&&(W=`https://${i.frontend_host}`),!W&&(i!=null&&i.frontend_host)&&(W=`https://${i.frontend_host}`),W&&u(W)}},[f,h,S,i,u,_]),a.useEffect(()=>{var N;if(!i)return;const W=new URLSearchParams(window.location.search).get("invite_token");if(I&&!W){v(!0);const D=((N=i.ui_settings)==null?void 0:N.waitlist_page_url)||`https://${i.frontend_host}/waitlist`;u(D);return}W&&!w&&r&&(C(W),r.validateDeploymentInvitation(W).then(D=>{y(D),D.valid&&p(Y=>({...Y,first_name:D.first_name||Y.first_name,last_name:D.last_name||Y.last_name,email:D.email||Y.email}))}).catch(D=>{console.error("Failed to validate invitation:",D)}))},[i,I,u,w,r]);const[T,E]=a.useState(!1),[j,R]=a.useState(""),M=fe=>{let{name:W,value:N}=fe.target;W==="phone_number"?N=N.replace(/[^0-9-]/g,""):W==="email"&&(N=N.toLowerCase()),p(D=>({...D,[W]:N})),x(D=>({...D,[W]:""}))},F=()=>{p({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),E(!1),R(""),n()},A=async fe=>{if(fe.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",L),console.log("Form data:",l),t||m)return;const W={},N=/^[a-zA-Z]{3,30}$/,D=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,Y=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,ie=/^\d{7,15}$/,J=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(L!=null&&L.first_name.enabled&&(L!=null&&L.first_name.required&&!l.first_name?W.first_name="First name is required":l.first_name&&!N.test(l.first_name)&&(W.first_name="Invalid name")),L!=null&&L.last_name.enabled&&(L!=null&&L.last_name.required&&!l.last_name?W.last_name="Last name is required":l.last_name&&!N.test(l.last_name)&&(W.last_name="Invalid last name")),L!=null&&L.username.enabled&&(L!=null&&L.username.required&&!l.username?W.username="Username is required":l.username&&!D.test(l.username)&&(W.username="Username must be 3-20 characters")),L!=null&&L.email_address.enabled&&(L!=null&&L.email_address.required&&!l.email?W.email="Email address is required":l.email&&!Y.test(l.email)&&(W.email="Invalid email address")),L!=null&&L.phone_number.enabled&&(L!=null&&L.phone_number.required&&!l.phone_number?W.phone_number="Phone number is required":l.phone_number&&!ie.test(l.phone_number)&&(W.phone_number="Phone number must contain 7-15 digits")),L!=null&&L.password.enabled&&(l.password?J.test(l.password)||(W.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):W.password="Password is required"),x(W),Object.keys(W).length>0){console.log("Signup validation failed. Errors:",W);return}console.log("Signup validation passed"),b(!0);try{const _e={...l};l.phone_number&&$&&(_e.phone_country_code=$),k&&(_e.invite_token=k),console.log("Submitting signup data:",_e),console.log("Phone number:",_e.phone_number),console.log("Phone country code:",_e.phone_country_code),await r.create(_e)}catch(_e){x({submit:_e.message})}finally{b(!1)}},B=async fe=>{if(!(t||m)){b(!0);try{const N=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:D}=await s.create({provider:fe.provider,redirectUri:N});D&&typeof D=="object"&&"oauth_url"in D&&(window.location.href=D.oauth_url)}catch(W){x({submit:W.message})}finally{b(!1)}}},O=(i==null?void 0:i.social_connections.filter(fe=>fe.enabled))||[],L=i==null?void 0:i.auth_settings,X=!!((le=L==null?void 0:L.first_name)!=null&&le.enabled&&((oe=L==null?void 0:L.last_name)!=null&&oe.enabled)),ee=async fe=>{var N;if(fe.preventDefault(),t||m)return;b(!0);const W={};if(!j){W.otp="OTP code is required",x(W),b(!1);return}x(W);try{const D=await r.completeVerification(j);"data"in D&&((N=D.data)!=null&&N.active_signin)&&await c()}catch(D){console.error("Verification failed:",D)}finally{b(!1)}};return a.useEffect(()=>{var fe;if(o){if(o.completed){let W=new URLSearchParams(window.location.search).get("redirect_uri");if(W||(W=((fe=i==null?void 0:i.ui_settings)==null?void 0:fe.after_signup_redirect_url)||null),!W&&(i!=null&&i.frontend_host)&&(W=`https://${i.frontend_host}`),W){let N;try{N=new URL(W)}catch{N=new URL(W,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&N.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),u(N.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}E(!0)}}},[o,r,T,i,f,u]),h?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(gi,{children:e.jsx(kt,{size:32})})]})}):_?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(gi,{children:e.jsx(kt,{size:32})})]})}):P?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(Cn,{children:e.jsx(Sn,{children:"Sign up Restricted!"})}),e.jsx(pf,{children:e.jsx(hf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(ff,{children:e.jsxs(gf,{children:["Need assistance?"," ",e.jsx(mf,{href:(de=i==null?void 0:i.ui_settings)!=null&&de.sign_in_page_url?`${i.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(ge,{children:e.jsx(oo,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(Cn,{children:[e.jsxs(Sn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(mi,{children:(o==null?void 0:o.current_step)==="verify_email"?`${l.email} to continue to ${(Z=i==null?void 0:i.ui_settings)==null?void 0:Z.app_name}`:`${l.phone_number} to continue to ${(se=i==null?void 0:i.ui_settings)==null?void 0:se.app_name}`})]}),e.jsxs(xi,{style:{gap:"15px"},onSubmit:ee,noValidate:!0,children:[e.jsx(Tt,{onComplete:async fe=>{R(fe)},onResend:async()=>{const fe=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:fe})},error:g.otp,isSubmitting:m}),e.jsx(vi,{type:"submit",disabled:m||t||!j,children:m?"Verifying...":`Continue to ${(xe=i==null?void 0:i.ui_settings)==null?void 0:xe.app_name}`})]}),e.jsxs(bi,{children:["Having trouble?"," ",e.jsx(zn,{children:e.jsx(ot,{to:i.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(zn,{onClick:()=>{F()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(Cn,{children:[e.jsx(Sn,{children:"Create your account"}),e.jsx(mi,{children:w!=null&&w.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),O.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Es,{connections:O,callback:B}),e.jsx(cf,{children:e.jsx(lf,{children:"or"})})]}),e.jsxs(xi,{onSubmit:A,noValidate:!0,children:[(((ue=L==null?void 0:L.first_name)==null?void 0:ue.enabled)||((U=L==null?void 0:L.last_name)==null?void 0:U.enabled))&&e.jsxs(df,{$isBothEnabled:X,children:[((pe=L==null?void 0:L.first_name)==null?void 0:pe.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"first_name",children:["First name",((K=L==null?void 0:L.first_name)==null?void 0:K.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(ce,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:M,placeholder:"First name","aria-invalid":!!g.first_name,pattern:"^[a-zA-Z]{3,30}$"}),g.first_name&&e.jsx(At,{children:g.first_name})]}),((H=L==null?void 0:L.last_name)==null?void 0:H.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"last_name",children:["Last name",((ne=L==null?void 0:L.last_name)==null?void 0:ne.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(ce,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:M,placeholder:"Last name","aria-invalid":!!g.last_name,pattern:"^[a-zA-Z]{3,30}$"}),g.last_name&&e.jsx(At,{children:g.last_name})]})]}),(L==null?void 0:L.username.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"username",children:["Username",L.username.required&&e.jsx(pr,{children:"*"})]}),e.jsx(ce,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:M,placeholder:"Choose a username","aria-invalid":!!g.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),g.username&&e.jsx(At,{children:g.username})]}),(L==null?void 0:L.email_address.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"email",children:["Email address",L.email_address.required&&e.jsx(pr,{children:"*"})]}),e.jsx(ce,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:M,placeholder:"Enter your email address","aria-invalid":!!g.email,required:!0,readOnly:(w==null?void 0:w.valid)&&!!(w!=null&&w.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),g.email&&e.jsx(At,{children:g.email})]}),(L==null?void 0:L.phone_number.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"phone_number",children:["Phone number",L.phone_number.required&&e.jsx(pr,{children:"*"})]}),e.jsx(qr,{value:l.phone_number,onChange:M,error:g.phone_number,countryCode:$,setCountryCode:z}),g.phone_number&&e.jsx(At,{children:g.phone_number})]}),(L==null?void 0:L.password.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"password",children:["Password",L.password.required&&e.jsx(pr,{children:"*"})]}),e.jsx(uf,{children:e.jsx(ce,{type:"password",id:"password",name:"password",value:l.password,onChange:M,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&&e.jsx(At,{children:g.password})]}),g.submit&&e.jsx(At,{children:g.submit}),e.jsx(vi,{type:"submit",disabled:m||t,children:m?"Creating account...":"Continue"})]}),e.jsxs(bi,{children:["Already have an account?"," ",e.jsx(zn,{children:e.jsx(ot,{to:`${(me=i.ui_settings)==null?void 0:me.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const ll=a.createContext(void 0),dl=()=>{const t=a.useContext(ll);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},vf=d.div`
924
+ `;function xf(){var V,q,re,ne,J,oe,de,Z,ae,xe,ue,U,pe,K,H,se,me;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=vc(),{signIn:s}=Br("oauth"),{deployment:a}=ve(),{navigate:p}=Ge(),{session:f,refetch:c,loading:h}=Ue(),[l,u]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[g,v]=i.useState({}),[x,w]=i.useState(!1),[$,S]=i.useState(void 0),[k,P]=i.useState(null),[E,z]=i.useState(null),[y,m]=i.useState(!1),b=((V=a==null?void 0:a.restrictions)==null?void 0:V.sign_up_mode)==="restricted",_=((q=a==null?void 0:a.restrictions)==null?void 0:q.sign_up_mode)==="waitlist",j=((ne=(re=a==null?void 0:a.auth_settings)==null?void 0:re.multi_session_support)==null?void 0:ne.enabled)??!1;i.useEffect(()=>{var fe;if(!h&&(f!=null&&f.active_signin)&&!j&&!y){m(!0);let W=new URLSearchParams(window.location.search).get("redirect_uri");W||(W=((fe=a==null?void 0:a.ui_settings)==null?void 0:fe.after_signin_redirect_url)||null),!W&&(a!=null&&a.frontend_host)&&(W=`https://${a.frontend_host}`),!W&&(a!=null&&a.frontend_host)&&(W=`https://${a.frontend_host}`),W&&p(W)}},[f,h,j,a,p,y]),i.useEffect(()=>{var N;if(!a)return;const W=new URLSearchParams(window.location.search).get("invite_token");if(_&&!W){m(!0);const D=((N=a.ui_settings)==null?void 0:N.waitlist_page_url)||`https://${a.frontend_host}/waitlist`;p(D);return}W&&!k&&r&&(z(W),r.validateDeploymentInvitation(W).then(D=>{P(D),D.valid&&u(Y=>({...Y,first_name:D.first_name||Y.first_name,last_name:D.last_name||Y.last_name,email:D.email||Y.email}))}).catch(D=>{console.error("Failed to validate invitation:",D)}))},[a,_,p,k,r]);const[T,R]=i.useState(!1),[C,I]=i.useState(""),M=fe=>{let{name:W,value:N}=fe.target;W==="phone_number"?N=N.replace(/[^0-9-]/g,""):W==="email"&&(N=N.toLowerCase()),u(D=>({...D,[W]:N})),v(D=>({...D,[W]:""}))},F=()=>{u({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),v({}),R(!1),I(""),n()},L=async fe=>{if(fe.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",l),t||x)return;const W={},N=/^[a-zA-Z]{3,30}$/,D=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,Y=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,ie=/^\d{7,15}$/,ee=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!l.first_name?W.first_name="First name is required":l.first_name&&!N.test(l.first_name)&&(W.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!l.last_name?W.last_name="Last name is required":l.last_name&&!N.test(l.last_name)&&(W.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!l.username?W.username="Username is required":l.username&&!D.test(l.username)&&(W.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!l.email?W.email="Email address is required":l.email&&!Y.test(l.email)&&(W.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!l.phone_number?W.phone_number="Phone number is required":l.phone_number&&!ie.test(l.phone_number)&&(W.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(l.password?ee.test(l.password)||(W.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):W.password="Password is required"),v(W),Object.keys(W).length>0){console.log("Signup validation failed. Errors:",W);return}console.log("Signup validation passed"),w(!0);try{const _e={...l};l.phone_number&&$&&(_e.phone_country_code=$),E&&(_e.invite_token=E),console.log("Submitting signup data:",_e),console.log("Phone number:",_e.phone_number),console.log("Phone country code:",_e.phone_country_code),await r.create(_e)}catch(_e){v({submit:_e.message})}finally{w(!1)}},B=async fe=>{if(!(t||x)){w(!0);try{const N=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:D}=await s.create({provider:fe.provider,redirectUri:N});D&&typeof D=="object"&&"oauth_url"in D&&(window.location.href=D.oauth_url)}catch(W){v({submit:W.message})}finally{w(!1)}}},O=(a==null?void 0:a.social_connections.filter(fe=>fe.enabled))||[],A=a==null?void 0:a.auth_settings,X=!!((J=A==null?void 0:A.first_name)!=null&&J.enabled&&((oe=A==null?void 0:A.last_name)!=null&&oe.enabled)),te=async fe=>{var N;if(fe.preventDefault(),t||x)return;w(!0);const W={};if(!C){W.otp="OTP code is required",v(W),w(!1);return}v(W);try{const D=await r.completeVerification(C);"data"in D&&((N=D.data)!=null&&N.active_signin)&&await c()}catch(D){console.error("Verification failed:",D)}finally{w(!1)}};return i.useEffect(()=>{var fe;if(o){if(o.completed){let W=new URLSearchParams(window.location.search).get("redirect_uri");if(W||(W=((fe=a==null?void 0:a.ui_settings)==null?void 0:fe.after_signup_redirect_url)||null),!W&&(a!=null&&a.frontend_host)&&(W=`https://${a.frontend_host}`),W){let N;try{N=new URL(W)}catch{N=new URL(W,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&N.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(N.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[o,r,T,a,f,p]),h?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(ga,{children:e.jsx(kt,{size:32})})]})}):y?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(ga,{children:e.jsx(kt,{size:32})})]})}):b?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(Cn,{children:e.jsx(Sn,{children:"Sign up Restricted!"})}),e.jsx(pf,{children:e.jsx(hf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(ff,{children:e.jsxs(gf,{children:["Need assistance?"," ",e.jsx(mf,{href:(de=a==null?void 0:a.ui_settings)!=null&&de.sign_in_page_url?`${a.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(ge,{children:e.jsx(oo,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(Cn,{children:[e.jsxs(Sn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ma,{children:(o==null?void 0:o.current_step)==="verify_email"?`${l.email} to continue to ${(Z=a==null?void 0:a.ui_settings)==null?void 0:Z.app_name}`:`${l.phone_number} to continue to ${(ae=a==null?void 0:a.ui_settings)==null?void 0:ae.app_name}`})]}),e.jsxs(xa,{style:{gap:"15px"},onSubmit:te,noValidate:!0,children:[e.jsx(Tt,{onComplete:async fe=>{I(fe)},onResend:async()=>{const fe=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:fe})},error:g.otp,isSubmitting:x}),e.jsx(va,{type:"submit",disabled:x||t||!C,children:x?"Verifying...":`Continue to ${(xe=a==null?void 0:a.ui_settings)==null?void 0:xe.app_name}`})]}),e.jsxs(ba,{children:["Having trouble?"," ",e.jsx(zn,{children:e.jsx(ot,{to:a.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(zn,{onClick:()=>{F()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(Cn,{children:[e.jsx(Sn,{children:"Create your account"}),e.jsx(ma,{children:k!=null&&k.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),O.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Es,{connections:O,callback:B}),e.jsx(cf,{children:e.jsx(lf,{children:"or"})})]}),e.jsxs(xa,{onSubmit:L,noValidate:!0,children:[(((ue=A==null?void 0:A.first_name)==null?void 0:ue.enabled)||((U=A==null?void 0:A.last_name)==null?void 0:U.enabled))&&e.jsxs(df,{$isBothEnabled:X,children:[((pe=A==null?void 0:A.first_name)==null?void 0:pe.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"first_name",children:["First name",((K=A==null?void 0:A.first_name)==null?void 0:K.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:M,placeholder:"First name","aria-invalid":!!g.first_name,pattern:"^[a-zA-Z]{3,30}$"}),g.first_name&&e.jsx(At,{children:g.first_name})]}),((H=A==null?void 0:A.last_name)==null?void 0:H.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"last_name",children:["Last name",((se=A==null?void 0:A.last_name)==null?void 0:se.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:M,placeholder:"Last name","aria-invalid":!!g.last_name,pattern:"^[a-zA-Z]{3,30}$"}),g.last_name&&e.jsx(At,{children:g.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:M,placeholder:"Choose a username","aria-invalid":!!g.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),g.username&&e.jsx(At,{children:g.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:M,placeholder:"Enter your email address","aria-invalid":!!g.email,required:!0,readOnly:(k==null?void 0:k.valid)&&!!(k!=null&&k.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),g.email&&e.jsx(At,{children:g.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(pr,{children:"*"})]}),e.jsx(qr,{value:l.phone_number,onChange:M,error:g.phone_number,countryCode:$,setCountryCode:S}),g.phone_number&&e.jsx(At,{children:g.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(pr,{children:"*"})]}),e.jsx(uf,{children:e.jsx(le,{type:"password",id:"password",name:"password",value:l.password,onChange:M,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&&e.jsx(At,{children:g.password})]}),g.submit&&e.jsx(At,{children:g.submit}),e.jsx(va,{type:"submit",disabled:x||t,children:x?"Creating account...":"Continue"})]}),e.jsxs(ba,{children:["Already have an account?"," ",e.jsx(zn,{children:e.jsx(ot,{to:`${(me=a.ui_settings)==null?void 0:me.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const ll=i.createContext(void 0),dl=()=>{const t=i.useContext(ll);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},vf=d.div`
925
925
  position: fixed;
926
926
  inset: 0;
927
927
  background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
@@ -971,7 +971,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
971
971
  gap: 8px;
972
972
  padding: 16px;
973
973
  border-top: 1px solid var(--color-border);
974
- `,Cf=({isOpen:t,onClose:r,children:o})=>{const[n,s]=a.useState(!1);return a.useEffect(()=>{s(!0);const i=u=>{u.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[t,r]),!t||!n?null:Wr.createPortal(e.jsx(ge,{children:e.jsx(ll.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},Sf=({children:t})=>{const{onClose:r}=dl(),o=a.useRef(null),n=s=>{o.current&&!o.current.contains(s.target)&&(r==null||r())};return e.jsx(vf,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},zf=({children:t,style:r})=>e.jsx(bf,{style:r,children:t}),$f=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=dl();return e.jsxs(yf,{children:[typeof t=="string"?e.jsx(wf,{children:t}):t,r&&e.jsx(jf,{onClick:o,children:e.jsx(et,{size:18})})]})},Ef=({children:t,style:r})=>e.jsx(_f,{style:r,children:t}),If=({children:t})=>e.jsx(kf,{children:t}),ke=Object.assign(Cf,{Overlay:Sf,Content:zf,Header:$f,Body:Ef,Footer:If}),Pf=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:s=!0})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{children:[o&&e.jsx(ke.Header,{showCloseButton:s,children:o}),e.jsx(ke.Body,{children:n})]})})}),Rf=({trigger:t,renderDialog:r})=>{const[o,n]=a.useState(!1),s=()=>n(!0),i=()=>n(!1);return e.jsxs(e.Fragment,{children:[t({onClick:s}),r({isOpen:o,onClose:i})]})},Tf=d.div`
974
+ `,Cf=({isOpen:t,onClose:r,children:o})=>{const[n,s]=i.useState(!1);return i.useEffect(()=>{s(!0);const a=p=>{p.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[t,r]),!t||!n?null:Wr.createPortal(e.jsx(ge,{children:e.jsx(ll.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},Sf=({children:t})=>{const{onClose:r}=dl(),o=i.useRef(null),n=s=>{o.current&&!o.current.contains(s.target)&&(r==null||r())};return e.jsx(vf,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},zf=({children:t,style:r})=>e.jsx(bf,{style:r,children:t}),$f=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=dl();return e.jsxs(yf,{children:[typeof t=="string"?e.jsx(wf,{children:t}):t,r&&e.jsx(jf,{onClick:o,children:e.jsx(et,{size:18})})]})},Ef=({children:t,style:r})=>e.jsx(_f,{style:r,children:t}),If=({children:t})=>e.jsx(kf,{children:t}),ke=Object.assign(Cf,{Overlay:Sf,Content:zf,Header:$f,Body:Ef,Footer:If}),Pf=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:s=!0})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{children:[o&&e.jsx(ke.Header,{showCloseButton:s,children:o}),e.jsx(ke.Body,{children:n})]})})}),Rf=({trigger:t,renderDialog:r})=>{const[o,n]=i.useState(!1),s=()=>n(!0),a=()=>n(!1);return e.jsxs(e.Fragment,{children:[t({onClick:s}),r({isOpen:o,onClose:a})]})},Tf=d.div`
975
975
  position: fixed;
976
976
  background: var(--color-background);
977
977
  border-radius: 8px;
@@ -983,7 +983,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
983
983
  display: grid;
984
984
  `,Mf=d.div`
985
985
  width: fit-content;
986
- `,ul=a.createContext(void 0),pl=()=>{const t=a.useContext(ul);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},nt=({children:t,open:r,openChange:o,style:n})=>{const s=a.useRef(null),[i,u]=a.useState(!1);return a.useEffect(()=>{const f=c=>{s.current&&!s.current.contains(c.target)&&u(!1)};return i&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[i,o]),a.useEffect(()=>{o==null||o(i)},[i]),a.useEffect(()=>{u(!!r)},[r]),e.jsx(ul.Provider,{value:{open:i,openChange:f=>u(f)},children:e.jsx(Mf,{style:n,ref:s,children:t})})},st=({children:t,style:r})=>{const{open:o}=pl(),[n,s]=a.useState({top:0,left:0}),[i,u]=a.useState(!1),f=a.useRef(null);return a.useEffect(()=>{o&&f.current?(u(!1),requestAnimationFrame(()=>{var l,p;const c=(l=f.current)==null?void 0:l.parentElement;if(!c)return;const h=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(h&&h!==f.current){const g=h.getBoundingClientRect(),x=(p=f.current)==null?void 0:p.getBoundingClientRect(),m=window.innerWidth,b=window.innerHeight;let $=g.bottom+4,z=g.right-200;z<8&&(z=g.left),z+200>m-8&&(z=m-208),x&&$+x.height>b-8&&($=g.top-(x.height+4)),s({top:$,left:z}),u(!0)}})):u(!1)},[o]),o?e.jsx(Tf,{ref:f,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:i?"visible":"hidden",opacity:i?1:0,transition:i?"opacity 0.15s ease-in-out":"none"},children:t}):null},it=({children:t})=>{const{openChange:r,open:o}=pl(),n=a.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Te=d.button`
986
+ `,ul=i.createContext(void 0),pl=()=>{const t=i.useContext(ul);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},nt=({children:t,open:r,openChange:o,style:n})=>{const s=i.useRef(null),[a,p]=i.useState(!1);return i.useEffect(()=>{const f=c=>{s.current&&!s.current.contains(c.target)&&p(!1)};return a&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[a,o]),i.useEffect(()=>{o==null||o(a)},[a]),i.useEffect(()=>{p(!!r)},[r]),e.jsx(ul.Provider,{value:{open:a,openChange:f=>p(f)},children:e.jsx(Mf,{style:n,ref:s,children:t})})},st=({children:t,style:r})=>{const{open:o}=pl(),[n,s]=i.useState({top:0,left:0}),[a,p]=i.useState(!1),f=i.useRef(null);return i.useEffect(()=>{o&&f.current?(p(!1),requestAnimationFrame(()=>{var l,u;const c=(l=f.current)==null?void 0:l.parentElement;if(!c)return;const h=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(h&&h!==f.current){const g=h.getBoundingClientRect(),v=(u=f.current)==null?void 0:u.getBoundingClientRect(),x=window.innerWidth,w=window.innerHeight;let $=g.bottom+4,S=g.right-200;S<8&&(S=g.left),S+200>x-8&&(S=x-208),v&&$+v.height>w-8&&($=g.top-(v.height+4)),s({top:$,left:S}),p(!0)}})):p(!1)},[o]),o?e.jsx(Tf,{ref:f,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:a?"visible":"hidden",opacity:a?1:0,transition:a?"opacity 0.15s ease-in-out":"none"},children:t}):null},at=({children:t})=>{const{openChange:r,open:o}=pl(),n=i.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Te=d.button`
987
987
  width: 100%;
988
988
  padding: 8px 12px;
989
989
  background: none;
@@ -1009,12 +1009,12 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1009
1009
  display: flex;
1010
1010
  flex-direction: column;
1011
1011
  gap: var(--space-xs);
1012
- `,ae=d.label`
1012
+ `,ce=d.label`
1013
1013
  font-size: var(--font-xs);
1014
1014
  text-align: left;
1015
1015
  font-weight: 400;
1016
1016
  color: var(--color-foreground);
1017
- `,Of=ir`
1017
+ `,Of=ar`
1018
1018
  0% {
1019
1019
  transform: rotate(0deg);
1020
1020
  }
@@ -1065,7 +1065,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1065
1065
  left: ${t=>t.checked?"20px":"2px"};
1066
1066
  transition: left 0.2s ease;
1067
1067
  }
1068
- `,Cr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(Df,{children:[e.jsx(Nf,{type:"checkbox",checked:t,onChange:o}),e.jsx(Ff,{checked:t})]})},Dr=(t=!1)=>{const[r,o]=a.useState(t),n=a.useCallback(()=>{o(!0)},[]),s=a.useCallback(()=>{o(!1)},[]),i=a.useCallback(()=>{o(u=>!u)},[]);return{isOpen:r,open:n,close:s,toggle:i}},zt=({onChange:t,placeholder:r,value:o})=>e.jsxs("div",{style:{display:"flex",flexGrow:1,alignItems:"center",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"8px 12px",backgroundColor:"var(--color-input-background)",minWidth:"250px"},children:[e.jsx(_h,{size:16,color:"var(--color-secondary-text)",style:{marginRight:"8px"}}),e.jsx("input",{type:"text",placeholder:r,value:o,onChange:n=>t(n.target.value),style:{border:"none",outline:"none",width:"100%",fontSize:"14px",color:"var(--color-text)",backgroundColor:"transparent"}})]}),Q=d.button`
1068
+ `,Cr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(Df,{children:[e.jsx(Nf,{type:"checkbox",checked:t,onChange:o}),e.jsx(Ff,{checked:t})]})},Dr=(t=!1)=>{const[r,o]=i.useState(t),n=i.useCallback(()=>{o(!0)},[]),s=i.useCallback(()=>{o(!1)},[]),a=i.useCallback(()=>{o(p=>!p)},[]);return{isOpen:r,open:n,close:s,toggle:a}},St=({onChange:t,placeholder:r,value:o})=>e.jsxs("div",{style:{display:"flex",flexGrow:1,alignItems:"center",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"8px 12px",backgroundColor:"var(--color-input-background)",minWidth:"250px"},children:[e.jsx(_h,{size:16,color:"var(--color-secondary-text)",style:{marginRight:"8px"}}),e.jsx("input",{type:"text",placeholder:r,value:o,onChange:n=>t(n.target.value),style:{border:"none",outline:"none",width:"100%",fontSize:"14px",color:"var(--color-text)",backgroundColor:"transparent"}})]}),Q=d.button`
1069
1069
  width: 100%;
1070
1070
  padding: var(--space-sm) var(--space-md);
1071
1071
  border: 1px solid transparent;
@@ -1207,7 +1207,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1207
1207
  text-transform: uppercase;
1208
1208
  color: var(--color-muted);
1209
1209
  background: var(--color-background-hover);
1210
- `,Is=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:s=!1,searchable:i=!1,width:u,name:f,id:c,groupsEnabled:h=!1,className:l})=>{const[p,g]=a.useState(!1),[x,m]=a.useState(""),b=a.useRef(null),$=a.useRef(null),z=h&&"options"in t[0],y=(z?t.flatMap(v=>v.options):t).find(v=>v.value===r),k=x?z?t.map(v=>({...v,options:v.options.filter(P=>P.label.toLowerCase().includes(x.toLowerCase()))})).filter(v=>v.options.length>0):t.filter(v=>v.label.toLowerCase().includes(x.toLowerCase())):t,C=(v,P=!1)=>{P||(o(v),g(!1),m(""))},_=()=>{s||g(!p)};return a.useEffect(()=>{p&&i&&$.current&&setTimeout(()=>{var v;(v=$.current)==null||v.focus()},10)},[p,i]),a.useEffect(()=>{const v=P=>{b.current&&!b.current.contains(P.target)&&(g(!1),m(""))};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),e.jsxs(hl,{ref:b,style:{width:u},className:l,children:[e.jsxs(fl,{type:"button",onClick:_,disabled:s,"aria-haspopup":"listbox","aria-expanded":p,id:c,children:[y?y.label:e.jsx(xl,{children:n}),p?e.jsx(tl,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(gl,{isOpen:p,role:"listbox",children:[i&&e.jsx(ml,{ref:$,type:"text",placeholder:"Search...",value:x,onChange:v=>m(v.target.value),onClick:v=>v.stopPropagation()}),z?k.map((v,P)=>e.jsxs(a.Fragment,{children:[e.jsx(vl,{children:v.label}),v.options.length===0?e.jsx(Vo,{children:"No options available"}):v.options.map(I=>e.jsxs(Wo,{isSelected:I.value===r,disabled:I.disabled,onClick:()=>C(I.value,I.disabled),role:"option","aria-selected":I.value===r,children:[I.label,I.value===r&&e.jsx(Ve,{size:16})]},I.value))]},`group-${P}`)):e.jsx(e.Fragment,{children:k.length===0?e.jsx(Vo,{children:"No options available"}):k.map(v=>e.jsxs(Wo,{isSelected:v.value===r,disabled:v.disabled,onClick:()=>C(v.value,v.disabled),role:"option","aria-selected":v.value===r,children:[v.label,v.value===r&&e.jsx(Ve,{size:16})]},v.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r||""})]})},bl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:s=!1,searchable:i=!1,width:u,name:f,id:c,groupsEnabled:h=!1,className:l})=>{const[p,g]=a.useState(!1),[x,m]=a.useState(""),b=a.useRef(null),$=a.useRef(null),z=h&&"options"in t[0],y=(z?t.flatMap(v=>v.options):t).filter(v=>r.includes(v.value)),k=x?z?t.map(v=>({...v,options:v.options.filter(P=>P.label.toLowerCase().includes(x.toLowerCase()))})).filter(v=>v.options.length>0):t.filter(v=>v.label.toLowerCase().includes(x.toLowerCase())):t,C=(v,P=!1)=>{P||(r.includes(v)?o(r.filter(I=>I!==v)):o([...r,v]))},_=()=>{s||g(!p)};return a.useEffect(()=>{p&&i&&$.current&&setTimeout(()=>{var v;(v=$.current)==null||v.focus()},10)},[p,i]),a.useEffect(()=>{const v=P=>{b.current&&!b.current.contains(P.target)&&(g(!1),m(""))};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),e.jsxs(hl,{ref:b,style:{width:u},className:l,children:[e.jsxs(fl,{type:"button",onClick:_,disabled:s,"aria-haspopup":"listbox","aria-expanded":p,id:c,children:[y.length>0?y.map(v=>v.label).join(", "):e.jsx(xl,{children:n}),p?e.jsx(tl,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(gl,{isOpen:p,role:"listbox",children:[i&&e.jsx(ml,{ref:$,type:"text",placeholder:"Search...",value:x,onChange:v=>m(v.target.value),onClick:v=>v.stopPropagation()}),z?k.map((v,P)=>e.jsxs(a.Fragment,{children:[e.jsx(vl,{children:v.label}),v.options.length===0?e.jsx(Vo,{children:"No options available"}):v.options.map(I=>e.jsxs(Wo,{isSelected:r.includes(I.value),disabled:I.disabled,onClick:()=>C(I.value,I.disabled),role:"option","aria-selected":r.includes(I.value),children:[I.label,r.includes(I.value)&&e.jsx(Ve,{size:16})]},I.value))]},`group-${P}`)):e.jsx(e.Fragment,{children:k.length===0?e.jsx(Vo,{children:"No options available"}):k.map(v=>e.jsxs(Wo,{isSelected:r.includes(v.value),disabled:v.disabled,onClick:()=>C(v.value,v.disabled),role:"option","aria-selected":r.includes(v.value),children:[v.label,r.includes(v.value)&&e.jsx(Ve,{size:16})]},v.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r.join(",")})]})},yl=a.createContext(void 0);function wl(){const t=a.useContext(yl);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function Bf({children:t}){const{deployment:r}=ve(),[o,n]=a.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[s,i]=a.useState(""),[u,f]=a.useState(!1),[c,h]=a.useState(!1),[l,p]=a.useState(!1),[g,x]=a.useState("identifier"),m=(r==null?void 0:r.social_connections.filter($=>$.enabled))||[],b=r==null?void 0:r.auth_settings;return e.jsx(yl.Provider,{value:{email:s,showOtherOptions:u,showForgotPassword:c,otpSent:l,setFirstFactor:n,setEmail:i,setShowOtherOptions:f,setShowForgotPassword:h,setOtpSent:p,enabledSocialsProviders:m,authSettings:b,firstFactor:o,signInStep:g,setSignInStep:x},children:t})}const Ir=d.button`
1210
+ `,Is=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:s=!1,searchable:a=!1,width:p,name:f,id:c,groupsEnabled:h=!1,className:l})=>{const[u,g]=i.useState(!1),[v,x]=i.useState(""),w=i.useRef(null),$=i.useRef(null),S=h&&"options"in t[0],P=(S?t.flatMap(m=>m.options):t).find(m=>m.value===r),E=v?S?t.map(m=>({...m,options:m.options.filter(b=>b.label.toLowerCase().includes(v.toLowerCase()))})).filter(m=>m.options.length>0):t.filter(m=>m.label.toLowerCase().includes(v.toLowerCase())):t,z=(m,b=!1)=>{b||(o(m),g(!1),x(""))},y=()=>{s||g(!u)};return i.useEffect(()=>{u&&a&&$.current&&setTimeout(()=>{var m;(m=$.current)==null||m.focus()},10)},[u,a]),i.useEffect(()=>{const m=b=>{w.current&&!w.current.contains(b.target)&&(g(!1),x(""))};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),e.jsxs(hl,{ref:w,style:{width:p},className:l,children:[e.jsxs(fl,{type:"button",onClick:y,disabled:s,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[P?P.label:e.jsx(xl,{children:n}),u?e.jsx(tl,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(gl,{isOpen:u,role:"listbox",children:[a&&e.jsx(ml,{ref:$,type:"text",placeholder:"Search...",value:v,onChange:m=>x(m.target.value),onClick:m=>m.stopPropagation()}),S?E.map((m,b)=>e.jsxs(i.Fragment,{children:[e.jsx(vl,{children:m.label}),m.options.length===0?e.jsx(Vo,{children:"No options available"}):m.options.map(_=>e.jsxs(Wo,{isSelected:_.value===r,disabled:_.disabled,onClick:()=>z(_.value,_.disabled),role:"option","aria-selected":_.value===r,children:[_.label,_.value===r&&e.jsx(Ve,{size:16})]},_.value))]},`group-${b}`)):e.jsx(e.Fragment,{children:E.length===0?e.jsx(Vo,{children:"No options available"}):E.map(m=>e.jsxs(Wo,{isSelected:m.value===r,disabled:m.disabled,onClick:()=>z(m.value,m.disabled),role:"option","aria-selected":m.value===r,children:[m.label,m.value===r&&e.jsx(Ve,{size:16})]},m.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r||""})]})},bl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:s=!1,searchable:a=!1,width:p,name:f,id:c,groupsEnabled:h=!1,className:l})=>{const[u,g]=i.useState(!1),[v,x]=i.useState(""),w=i.useRef(null),$=i.useRef(null),S=h&&"options"in t[0],P=(S?t.flatMap(m=>m.options):t).filter(m=>r.includes(m.value)),E=v?S?t.map(m=>({...m,options:m.options.filter(b=>b.label.toLowerCase().includes(v.toLowerCase()))})).filter(m=>m.options.length>0):t.filter(m=>m.label.toLowerCase().includes(v.toLowerCase())):t,z=(m,b=!1)=>{b||(r.includes(m)?o(r.filter(_=>_!==m)):o([...r,m]))},y=()=>{s||g(!u)};return i.useEffect(()=>{u&&a&&$.current&&setTimeout(()=>{var m;(m=$.current)==null||m.focus()},10)},[u,a]),i.useEffect(()=>{const m=b=>{w.current&&!w.current.contains(b.target)&&(g(!1),x(""))};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),e.jsxs(hl,{ref:w,style:{width:p},className:l,children:[e.jsxs(fl,{type:"button",onClick:y,disabled:s,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[P.length>0?P.map(m=>m.label).join(", "):e.jsx(xl,{children:n}),u?e.jsx(tl,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(gl,{isOpen:u,role:"listbox",children:[a&&e.jsx(ml,{ref:$,type:"text",placeholder:"Search...",value:v,onChange:m=>x(m.target.value),onClick:m=>m.stopPropagation()}),S?E.map((m,b)=>e.jsxs(i.Fragment,{children:[e.jsx(vl,{children:m.label}),m.options.length===0?e.jsx(Vo,{children:"No options available"}):m.options.map(_=>e.jsxs(Wo,{isSelected:r.includes(_.value),disabled:_.disabled,onClick:()=>z(_.value,_.disabled),role:"option","aria-selected":r.includes(_.value),children:[_.label,r.includes(_.value)&&e.jsx(Ve,{size:16})]},_.value))]},`group-${b}`)):e.jsx(e.Fragment,{children:E.length===0?e.jsx(Vo,{children:"No options available"}):E.map(m=>e.jsxs(Wo,{isSelected:r.includes(m.value),disabled:m.disabled,onClick:()=>z(m.value,m.disabled),role:"option","aria-selected":r.includes(m.value),children:[m.label,r.includes(m.value)&&e.jsx(Ve,{size:16})]},m.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r.join(",")})]})},yl=i.createContext(void 0);function wl(){const t=i.useContext(yl);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function Bf({children:t}){const{deployment:r}=ve(),[o,n]=i.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[s,a]=i.useState(""),[p,f]=i.useState(!1),[c,h]=i.useState(!1),[l,u]=i.useState(!1),[g,v]=i.useState("identifier"),x=(r==null?void 0:r.social_connections.filter($=>$.enabled))||[],w=r==null?void 0:r.auth_settings;return e.jsx(yl.Provider,{value:{email:s,showOtherOptions:p,showForgotPassword:c,otpSent:l,setFirstFactor:n,setEmail:a,setShowOtherOptions:f,setShowForgotPassword:h,setOtpSent:u,enabledSocialsProviders:x,authSettings:w,firstFactor:o,signInStep:g,setSignInStep:v},children:t})}const Ir=d.button`
1211
1211
  width: 100%;
1212
1212
  padding: var(--space-sm) var(--space-md);
1213
1213
  background: var(--color-input-background);
@@ -1230,7 +1230,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1230
1230
  opacity: 0.7;
1231
1231
  cursor: not-allowed;
1232
1232
  }
1233
- `;function jl(){const{deployment:t}=ve(),{signIn:r}=Br("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:s,setShowForgotPassword:i}=wl(),[u,f]=a.useState(!1),c=t==null?void 0:t.auth_settings,h=(t==null?void 0:t.social_connections.filter(g=>g.enabled))||[],l=async g=>{if(!u){f(!0);try{const{data:x}=await r.create({provider:g.provider});x&&typeof x=="object"&&"oauth_url"in x&&(window.location.href=x.oauth_url)}catch{}finally{f(!1)}}},p=()=>{i(!1),s(!1)};return e.jsxs(e.Fragment,{children:[h.length>0&&e.jsx(Es,{connections:h,callback:l}),e.jsxs("div",{children:[n!=="email_magic_link"&&(c==null?void 0:c.auth_factors_enabled.email_magic_link)&&e.jsx(Ir,{onClick:()=>{o("email_magic_link"),p()},children:"Get a magic link on your email"}),n!=="email_password"&&(c==null?void 0:c.auth_factors_enabled.email_password)&&e.jsx(Ir,{onClick:()=>{o("email_password"),p()},children:"Sign in with email and password"}),n!=="email_otp"&&(c==null?void 0:c.auth_factors_enabled.email_otp)&&e.jsx(Ir,{onClick:()=>{o("email_otp"),p()},children:"Sign in with email and OTP"}),n!=="phone_otp"&&(c==null?void 0:c.auth_factors_enabled.phone_otp)&&e.jsx(Ir,{onClick:()=>{o("phone_otp"),p()},children:"Sign in with phone number"}),n!=="username_password"&&(c==null?void 0:c.auth_factors_enabled.username_password)&&e.jsx(Ir,{onClick:()=>{o("username_password"),p()},children:"Sign in with username and password"})]})]})}const Uf=d.div`
1233
+ `;function jl(){const{deployment:t}=ve(),{signIn:r}=Br("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:s,setShowForgotPassword:a}=wl(),[p,f]=i.useState(!1),c=t==null?void 0:t.auth_settings,h=(t==null?void 0:t.social_connections.filter(g=>g.enabled))||[],l=async g=>{if(!p){f(!0);try{const{data:v}=await r.create({provider:g.provider});v&&typeof v=="object"&&"oauth_url"in v&&(window.location.href=v.oauth_url)}catch{}finally{f(!1)}}},u=()=>{a(!1),s(!1)};return e.jsxs(e.Fragment,{children:[h.length>0&&e.jsx(Es,{connections:h,callback:l}),e.jsxs("div",{children:[n!=="email_magic_link"&&(c==null?void 0:c.auth_factors_enabled.email_magic_link)&&e.jsx(Ir,{onClick:()=>{o("email_magic_link"),u()},children:"Get a magic link on your email"}),n!=="email_password"&&(c==null?void 0:c.auth_factors_enabled.email_password)&&e.jsx(Ir,{onClick:()=>{o("email_password"),u()},children:"Sign in with email and password"}),n!=="email_otp"&&(c==null?void 0:c.auth_factors_enabled.email_otp)&&e.jsx(Ir,{onClick:()=>{o("email_otp"),u()},children:"Sign in with email and OTP"}),n!=="phone_otp"&&(c==null?void 0:c.auth_factors_enabled.phone_otp)&&e.jsx(Ir,{onClick:()=>{o("phone_otp"),u()},children:"Sign in with phone number"}),n!=="username_password"&&(c==null?void 0:c.auth_factors_enabled.username_password)&&e.jsx(Ir,{onClick:()=>{o("username_password"),u()},children:"Sign in with username and password"})]})]})}const Uf=d.div`
1234
1234
  max-width: 380px;
1235
1235
  width: 380px;
1236
1236
  padding: var(--space-3xl);
@@ -1280,7 +1280,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1280
1280
  }
1281
1281
  `,Gf=d.span`
1282
1282
  white-space: nowrap;
1283
- `,io=d.div`
1283
+ `,ao=d.div`
1284
1284
  text-align: center;
1285
1285
  margin-top: var(--space-lg);
1286
1286
  `,Pr=d.p`
@@ -1294,7 +1294,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1294
1294
  &:hover {
1295
1295
  text-decoration: underline;
1296
1296
  }
1297
- `;function Hf({onBack:t}){const{deployment:r}=ve(),{navigate:o}=Ge(),[n,s]=a.useState("start"),[i,u]=a.useState(""),[f,c]=a.useState(""),[h,l]=a.useState(""),[p,g]=a.useState(""),[x,m]=a.useState(""),{forgotPassword:b,verifyOtp:$,resetPassword:z}=kc(),[w,y]=a.useState(!1),[k,C]=a.useState(null),_=async S=>{if(S.preventDefault(),!!i){y(!0),C(null);try{await b(i),s("otp")}catch(T){C(T)}finally{y(!1)}}},v=async S=>{if(S.preventDefault(),f.length===6){y(!0),C(null);try{const T=await $(i,f);T.data&&(l(T.data.token),s("reset"))}catch(T){C(T)}finally{y(!1)}}},P=async S=>{var T,E;if(S.preventDefault(),p===x&&!(p.length<8)){y(!0),C(null);try{const j=await z(h,p);if(j.data){const R=j.data,M=R.signin_attempts&&R.signin_attempts.length>0?R.signin_attempts[R.signin_attempts.length-1]:null;if(M&&!M.completed){const F=(T=r==null?void 0:r.ui_settings)==null?void 0:T.sign_in_page_url;if(F){const A=new URL(F,window.location.origin);A.searchParams.set("signin_attempt_id",M.id),o(A.toString())}else t()}else{const F=((E=r==null?void 0:r.ui_settings)==null?void 0:E.after_signin_redirect_url)||"/";o(F)}}}catch(j){C(j)}finally{y(!1)}}},I=()=>e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsx(no,{children:e.jsx(so,{children:"Forgot Password"})}),e.jsx(Wf,{onClick:()=>s("email"),disabled:w,children:"Reset your password"}),e.jsx(Vf,{children:e.jsx(Gf,{children:"Or, sign in with another method"})}),e.jsx(jl,{}),e.jsxs(io,{children:[e.jsxs(Pr,{children:["Unable to reset password? ",e.jsx(Rr,{href:"/contact",children:"Get help"})]}),e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(ge,{children:e.jsxs(Uf,{children:[n==="start"&&I(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Forgot Password"}),e.jsx($n,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(dt,{onSubmit:_,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"email",children:"Email Address"}),e.jsx(ce,{type:"email",id:"email",value:i,onChange:S=>u(S.target.value),placeholder:"Enter your email",required:!0})]}),k&&e.jsx(En,{children:k.message}),e.jsx(Q,{type:"submit",disabled:w,style:{width:"100%",marginTop:"var(--space-md)"},children:w?"Sending...":"Send Code"})]}),e.jsx(io,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Enter Verification Code"}),e.jsxs($n,{children:["We've sent a 6-digit code to ",i,". Please enter it below."]})]}),e.jsxs(dt,{onSubmit:v,noValidate:!0,children:[e.jsx(Tt,{onComplete:S=>c(S),isSubmitting:w,error:k==null?void 0:k.message,onResend:async()=>{await b(i)}}),k&&e.jsx(En,{children:k.message}),e.jsx(Q,{type:"submit",disabled:w||f.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:w?"Verifying...":"Verify"})]}),e.jsx(io,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Reset Password"}),e.jsx($n,{children:"Create a new password for your account."})]}),e.jsxs(dt,{onSubmit:P,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"password",children:"New Password"}),e.jsx(ce,{type:"password",id:"password",value:p,onChange:S=>g(S.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(ce,{type:"password",id:"confirmPassword",value:x,onChange:S=>m(S.target.value),placeholder:"Confirm new password",required:!0})]}),k&&e.jsx(En,{children:k.message}),e.jsx(Q,{type:"submit",disabled:w,style:{width:"100%",marginTop:"var(--space-md)"},children:w?"Resetting...":"Reset Password"})]}),e.jsx(io,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const qf=d.div`
1297
+ `;function Hf({onBack:t}){const{deployment:r}=ve(),{navigate:o}=Ge(),[n,s]=i.useState("start"),[a,p]=i.useState(""),[f,c]=i.useState(""),[h,l]=i.useState(""),[u,g]=i.useState(""),[v,x]=i.useState(""),{forgotPassword:w,verifyOtp:$,resetPassword:S}=kc(),[k,P]=i.useState(!1),[E,z]=i.useState(null),y=async j=>{if(j.preventDefault(),!!a){P(!0),z(null);try{await w(a),s("otp")}catch(T){z(T)}finally{P(!1)}}},m=async j=>{if(j.preventDefault(),f.length===6){P(!0),z(null);try{const T=await $(a,f);T.data&&(l(T.data.token),s("reset"))}catch(T){z(T)}finally{P(!1)}}},b=async j=>{var T,R;if(j.preventDefault(),u===v&&!(u.length<8)){P(!0),z(null);try{const C=await S(h,u);if(C.data){const I=C.data,M=I.signin_attempts&&I.signin_attempts.length>0?I.signin_attempts[I.signin_attempts.length-1]:null;if(M&&!M.completed){const F=(T=r==null?void 0:r.ui_settings)==null?void 0:T.sign_in_page_url;if(F){const L=new URL(F,window.location.origin);L.searchParams.set("signin_attempt_id",M.id),o(L.toString())}else t()}else{const F=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";o(F)}}}catch(C){z(C)}finally{P(!1)}}},_=()=>e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsx(no,{children:e.jsx(so,{children:"Forgot Password"})}),e.jsx(Wf,{onClick:()=>s("email"),disabled:k,children:"Reset your password"}),e.jsx(Vf,{children:e.jsx(Gf,{children:"Or, sign in with another method"})}),e.jsx(jl,{}),e.jsxs(ao,{children:[e.jsxs(Pr,{children:["Unable to reset password? ",e.jsx(Rr,{href:"/contact",children:"Get help"})]}),e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(ge,{children:e.jsxs(Uf,{children:[n==="start"&&_(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Forgot Password"}),e.jsx($n,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(dt,{onSubmit:y,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"email",children:"Email Address"}),e.jsx(le,{type:"email",id:"email",value:a,onChange:j=>p(j.target.value),placeholder:"Enter your email",required:!0})]}),E&&e.jsx(En,{children:E.message}),e.jsx(Q,{type:"submit",disabled:k,style:{width:"100%",marginTop:"var(--space-md)"},children:k?"Sending...":"Send Code"})]}),e.jsx(ao,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Enter Verification Code"}),e.jsxs($n,{children:["We've sent a 6-digit code to ",a,". Please enter it below."]})]}),e.jsxs(dt,{onSubmit:m,noValidate:!0,children:[e.jsx(Tt,{onComplete:j=>c(j),isSubmitting:k,error:E==null?void 0:E.message,onResend:async()=>{await w(a)}}),E&&e.jsx(En,{children:E.message}),e.jsx(Q,{type:"submit",disabled:k||f.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:k?"Verifying...":"Verify"})]}),e.jsx(ao,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Reset Password"}),e.jsx($n,{children:"Create a new password for your account."})]}),e.jsxs(dt,{onSubmit:b,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"password",children:"New Password"}),e.jsx(le,{type:"password",id:"password",value:u,onChange:j=>g(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(le,{type:"password",id:"confirmPassword",value:v,onChange:j=>x(j.target.value),placeholder:"Confirm new password",required:!0})]}),E&&e.jsx(En,{children:E.message}),e.jsx(Q,{type:"submit",disabled:k,style:{width:"100%",marginTop:"var(--space-md)"},children:k?"Resetting...":"Reset Password"})]}),e.jsx(ao,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const qf=d.div`
1298
1298
  max-width: 360px;
1299
1299
  width: 360px;
1300
1300
  padding: var(--space-2xl);
@@ -1318,13 +1318,13 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1318
1318
  `,Qf=d.div`
1319
1319
  text-align: center;
1320
1320
  margin-top: var(--space-lg);
1321
- `,yi=d.p`
1321
+ `,ya=d.p`
1322
1322
  font-size: var(--font-xs);
1323
1323
  color: var(--color-muted);
1324
- `,wi=d.a`
1324
+ `,wa=d.a`
1325
1325
  color: var(--color-primary);
1326
1326
  text-decoration: none;
1327
- `;function Xf({onBack:t}){return e.jsx(ge,{children:e.jsxs(qf,{children:[e.jsx(Pe,{}),e.jsxs(Yf,{children:[e.jsx(Zf,{children:"Supported Options"}),e.jsx(Kf,{children:"Choose one of the following options to continue"})]}),e.jsx(jl,{}),e.jsxs(Qf,{children:[e.jsxs(yi,{children:["Don't have an account? ",e.jsx(wi,{href:"/signup",children:"Sign up"})]}),e.jsx(yi,{style:{marginTop:"var(--space-sm)"},children:e.jsx(wi,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Jf=d.div`
1327
+ `;function Xf({onBack:t}){return e.jsx(ge,{children:e.jsxs(qf,{children:[e.jsx(Pe,{}),e.jsxs(Yf,{children:[e.jsx(Zf,{children:"Supported Options"}),e.jsx(Kf,{children:"Choose one of the following options to continue"})]}),e.jsx(jl,{}),e.jsxs(Qf,{children:[e.jsxs(ya,{children:["Don't have an account? ",e.jsx(wa,{href:"/signup",children:"Sign up"})]}),e.jsx(ya,{style:{marginTop:"var(--space-sm)"},children:e.jsx(wa,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Jf=d.div`
1328
1328
  max-width: 380px;
1329
1329
  width: 380px;
1330
1330
  padding: var(--space-3xl);
@@ -1388,11 +1388,11 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1388
1388
  display: flex;
1389
1389
  flex-direction: column;
1390
1390
  gap: var(--space-2xs);
1391
- `,ig=d.div`
1391
+ `,ag=d.div`
1392
1392
  font-weight: 400;
1393
1393
  font-size: var(--font-sm);
1394
1394
  color: var(--color-foreground);
1395
- `,ag=d.div`
1395
+ `,ig=d.div`
1396
1396
  font-size: var(--font-xs);
1397
1397
  color: var(--color-secondary-text);
1398
1398
  line-height: 1.4;
@@ -1411,7 +1411,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1411
1411
  &:hover {
1412
1412
  color: var(--color-primary-hover);
1413
1413
  }
1414
- `;function _l({methods:t,onSelectMethod:r,onBack:o}){const n=s=>{r(s)};return e.jsx(ge,{children:e.jsxs(Jf,{children:[e.jsx(Pe,{}),e.jsxs(eg,{children:[e.jsx(tg,{children:"Two-factor authentication"}),e.jsx(rg,{children:"Choose how you'd like to verify your identity"})]}),e.jsx(og,{children:t.map(s=>e.jsxs(ng,{onClick:()=>n(s.id),disabled:!s.available,type:"button",children:[s.icon,e.jsxs(sg,{children:[e.jsx(ig,{children:s.name}),e.jsxs(ag,{children:[s.description,s.phoneNumber&&` ${s.phoneNumber}`]})]})]},s.id))}),o&&e.jsx(cg,{children:e.jsx(lg,{onClick:o,style:{cursor:"pointer"},children:"Back to login"})})]})})}const dg=d.div`
1414
+ `;function _l({methods:t,onSelectMethod:r,onBack:o}){const n=s=>{r(s)};return e.jsx(ge,{children:e.jsxs(Jf,{children:[e.jsx(Pe,{}),e.jsxs(eg,{children:[e.jsx(tg,{children:"Two-factor authentication"}),e.jsx(rg,{children:"Choose how you'd like to verify your identity"})]}),e.jsx(og,{children:t.map(s=>e.jsxs(ng,{onClick:()=>n(s.id),disabled:!s.available,type:"button",children:[s.icon,e.jsxs(sg,{children:[e.jsx(ag,{children:s.name}),e.jsxs(ig,{children:[s.description,s.phoneNumber&&` ${s.phoneNumber}`]})]})]},s.id))}),o&&e.jsx(cg,{children:e.jsx(lg,{onClick:o,style:{cursor:"pointer"},children:"Back to login"})})]})})}const dg=d.div`
1415
1415
  max-width: 380px;
1416
1416
  width: 380px;
1417
1417
  padding: var(--space-3xl);
@@ -1454,16 +1454,16 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1454
1454
  &:hover {
1455
1455
  color: var(--color-primary-hover);
1456
1456
  }
1457
- `,vg=d(ce)`
1457
+ `,vg=d(le)`
1458
1458
  padding: var(--space-sm) var(--space-md);
1459
- `;function kl({onVerify:t,onBack:r,loading:o}){const[n,s]=a.useState(""),[i,u]=a.useState(""),f=h=>{if(h.preventDefault(),n.length!==4){u("Please enter the last 4 digits of your phone number");return}t(n)},c=h=>{const l=h.target.value.replace(/\D/g,"").slice(0,4);s(l),u("")};return e.jsx(ge,{children:e.jsxs(dg,{children:[e.jsx(Pe,{}),e.jsxs(ug,{children:[e.jsx(pg,{children:"Verify your phone number"}),e.jsx(hg,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(dt,{onSubmit:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(vg,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!i,autoFocus:!0}),i&&e.jsx(fg,{children:i})]}),e.jsx(gg,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(mg,{children:e.jsx(xg,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const bg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),yg=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),wg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),In=d.div`
1459
+ `;function kl({onVerify:t,onBack:r,loading:o}){const[n,s]=i.useState(""),[a,p]=i.useState(""),f=h=>{if(h.preventDefault(),n.length!==4){p("Please enter the last 4 digits of your phone number");return}t(n)},c=h=>{const l=h.target.value.replace(/\D/g,"").slice(0,4);s(l),p("")};return e.jsx(ge,{children:e.jsxs(dg,{children:[e.jsx(Pe,{}),e.jsxs(ug,{children:[e.jsx(pg,{children:"Verify your phone number"}),e.jsx(hg,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(dt,{onSubmit:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(vg,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!a,autoFocus:!0}),a&&e.jsx(fg,{children:a})]}),e.jsx(gg,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(mg,{children:e.jsx(xg,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const bg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),yg=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),wg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),In=d.div`
1460
1460
  max-width: 380px;
1461
1461
  width: 380px;
1462
1462
  padding: var(--space-3xl);
1463
1463
  background: var(--color-background);
1464
1464
  border-radius: var(--radius-lg);
1465
1465
  box-shadow: 0 4px 12px var(--color-shadow);
1466
- `,jg=ir`
1466
+ `,jg=ar`
1467
1467
  from {
1468
1468
  transform: rotate(0deg);
1469
1469
  }
@@ -1480,27 +1480,27 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1480
1480
  animation: ${jg} 1s linear infinite;
1481
1481
  color: var(--color-primary);
1482
1482
  }
1483
- `,ji=d.div`
1483
+ `,ja=d.div`
1484
1484
  text-align: center;
1485
1485
  margin-bottom: var(--space-lg);
1486
1486
  position: relative;
1487
- `,_i=d.h1`
1487
+ `,_a=d.h1`
1488
1488
  font-size: var(--font-lg);
1489
1489
  font-weight: 400;
1490
1490
  color: var(--color-foreground);
1491
1491
  margin-bottom: var(--space-xs);
1492
1492
  margin-top: 0;
1493
- `,ki=d.p`
1493
+ `,ka=d.p`
1494
1494
  color: var(--color-secondary-text);
1495
1495
  font-size: var(--font-xs);
1496
- `,Ci=d.p`
1496
+ `,Ca=d.p`
1497
1497
  font-size: var(--font-2xs);
1498
1498
  color: var(--color-error);
1499
1499
  margin: 0;
1500
1500
  margin-top: var(--space-2xs);
1501
1501
  `,kg=d(Q)`
1502
1502
  margin-top: var(--space-sm);
1503
- `,Si=d.div`
1503
+ `,Sa=d.div`
1504
1504
  margin-top: var(--space-lg);
1505
1505
  text-align: center;
1506
1506
  font-size: var(--font-xs);
@@ -1515,26 +1515,26 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1515
1515
  &:hover {
1516
1516
  color: var(--color-primary-hover);
1517
1517
  }
1518
- `,Cg=d(ce)`
1518
+ `,Cg=d(le)`
1519
1519
  padding: var(--space-sm) var(--space-md);
1520
- `;function Cl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:s}=ve(),[i,u]=a.useState(""),[f,c]=a.useState({}),[h,l]=a.useState(!1),[p,g]=a.useState(null),[x,m]=a.useState(!0),[b,$]=a.useState(!1),[z,w]=a.useState(""),[y,k]=a.useState(!1),{navigate:C}=Ge(),_=(r==null?void 0:r.available_2fa_methods)||[],v=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(bg,{}),available:_.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(yg,{}),available:_.includes("phone_otp"),phoneNumber:z},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(wg,{}),available:_.includes("backup_code")}].filter(E=>E.available),P=async E=>{g(E),m(!1),E==="phone_otp"&&$(!0)},I=async E=>{var j,R;if(r){l(!0);try{const M=await n({strategy:"phone_otp",lastDigits:E});M&&"data"in M&&((j=M.data)!=null&&j.otp_sent)?((R=M.data)!=null&&R.masked_phone&&w(M.data.masked_phone),$(!1)):c({phone:"Phone number verification failed"})}catch(M){c({phone:M.message})}finally{l(!1)}}},S=async(E,j)=>{if(E.preventDefault(),h)return;const R=j||i,M={};if(R?p==="authenticator"&&R.length!==6?M.code="Authentication code must be 6 digits":p==="phone_otp"&&R.length!==6&&(M.code="SMS code must be 6 digits"):M.code="Verification code is required",c(M),!(Object.keys(M).length>0)){l(!0);try{await o(R)}catch(F){c({submit:F.message})}finally{l(!1)}}},T=E=>{let j=E.target.value;p!=="backup_code"&&(j=j.replace(/\D/g,"").slice(0,6)),u(j),c(R=>({...R,code:""}))};return a.useEffect(()=>{var E;if(r.completed){k(!0);let j=new URLSearchParams(window.location.search).get("redirect_uri");if(j||(j=((E=s==null?void 0:s.ui_settings)==null?void 0:E.after_signin_redirect_url)||null),!j&&(s!=null&&s.frontend_host)&&(j=`https://${s.frontend_host}`),j){let R;try{R=new URL(j)}catch{R=new URL(j,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),C(R.toString())}return}},[r,s]),y?e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsx(_g,{children:e.jsx(kt,{size:32})})]})}):x?v.length===0?e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(ji,{children:[e.jsx(_i,{children:"Set Up Two-Factor Authentication"}),e.jsx(ki,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),e.jsxs(Si,{children:[t&&e.jsx("div",{children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Tr,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(_l,{methods:v,onSelectMethod:P,onBack:t}):b&&p==="phone_otp"?e.jsx(kl,{onVerify:I,onBack:()=>{$(!1),m(!0),g(null)},loading:h}):e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(ji,{children:[e.jsx(_i,{children:"Two-factor authentication"}),e.jsxs(ki,{children:[p==="authenticator"&&"Enter the 6-digit code from your authenticator app",p==="phone_otp"&&`Enter the 6-digit code sent to your phone ${z}`,p==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(dt,{onSubmit:S,noValidate:!0,children:[p==="backup_code"?e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"code",children:"Backup code"}),e.jsx(Cg,{type:"text",id:"code",name:"code",value:i,onChange:T,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!f.code,autoFocus:!0}),f.code&&e.jsx(Ci,{children:f.code})]}):e.jsx(Tt,{onComplete:async E=>{if(u(E),p!=="backup_code"){const j=new Event("submit",{bubbles:!0,cancelable:!0});await S(j,E)}},onResend:p==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:z.slice(-4)})}catch(E){c({submit:E.message})}}:void 0,error:f.code,isSubmitting:h}),e.jsxs("div",{children:[f.submit&&e.jsx(Ci,{children:f.submit}),e.jsx(kg,{type:"submit",disabled:h||!i,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(Si,{children:[e.jsx(Tr,{onClick:()=>{m(!0),g(null),u(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Tr,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Pn=d.div`
1520
+ `;function Cl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:s}=ve(),[a,p]=i.useState(""),[f,c]=i.useState({}),[h,l]=i.useState(!1),[u,g]=i.useState(null),[v,x]=i.useState(!0),[w,$]=i.useState(!1),[S,k]=i.useState(""),[P,E]=i.useState(!1),{navigate:z}=Ge(),y=(r==null?void 0:r.available_2fa_methods)||[],m=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(bg,{}),available:y.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(yg,{}),available:y.includes("phone_otp"),phoneNumber:S},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(wg,{}),available:y.includes("backup_code")}].filter(R=>R.available),b=async R=>{g(R),x(!1),R==="phone_otp"&&$(!0)},_=async R=>{var C,I;if(r){l(!0);try{const M=await n({strategy:"phone_otp",lastDigits:R});M&&"data"in M&&((C=M.data)!=null&&C.otp_sent)?((I=M.data)!=null&&I.masked_phone&&k(M.data.masked_phone),$(!1)):c({phone:"Phone number verification failed"})}catch(M){c({phone:M.message})}finally{l(!1)}}},j=async(R,C)=>{if(R.preventDefault(),h)return;const I=C||a,M={};if(I?u==="authenticator"&&I.length!==6?M.code="Authentication code must be 6 digits":u==="phone_otp"&&I.length!==6&&(M.code="SMS code must be 6 digits"):M.code="Verification code is required",c(M),!(Object.keys(M).length>0)){l(!0);try{await o(I)}catch(F){c({submit:F.message})}finally{l(!1)}}},T=R=>{let C=R.target.value;u!=="backup_code"&&(C=C.replace(/\D/g,"").slice(0,6)),p(C),c(I=>({...I,code:""}))};return i.useEffect(()=>{var R;if(r.completed){E(!0);let C=new URLSearchParams(window.location.search).get("redirect_uri");if(C||(C=((R=s==null?void 0:s.ui_settings)==null?void 0:R.after_signin_redirect_url)||null),!C&&(s!=null&&s.frontend_host)&&(C=`https://${s.frontend_host}`),C){let I;try{I=new URL(C)}catch{I=new URL(C,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&I.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),z(I.toString())}return}},[r,s]),P?e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsx(_g,{children:e.jsx(kt,{size:32})})]})}):v?m.length===0?e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(ja,{children:[e.jsx(_a,{children:"Set Up Two-Factor Authentication"}),e.jsx(ka,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),e.jsxs(Sa,{children:[t&&e.jsx("div",{children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Tr,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(_l,{methods:m,onSelectMethod:b,onBack:t}):w&&u==="phone_otp"?e.jsx(kl,{onVerify:_,onBack:()=>{$(!1),x(!0),g(null)},loading:h}):e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(ja,{children:[e.jsx(_a,{children:"Two-factor authentication"}),e.jsxs(ka,{children:[u==="authenticator"&&"Enter the 6-digit code from your authenticator app",u==="phone_otp"&&`Enter the 6-digit code sent to your phone ${S}`,u==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(dt,{onSubmit:j,noValidate:!0,children:[u==="backup_code"?e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"code",children:"Backup code"}),e.jsx(Cg,{type:"text",id:"code",name:"code",value:a,onChange:T,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!f.code,autoFocus:!0}),f.code&&e.jsx(Ca,{children:f.code})]}):e.jsx(Tt,{onComplete:async R=>{if(p(R),u!=="backup_code"){const C=new Event("submit",{bubbles:!0,cancelable:!0});await j(C,R)}},onResend:u==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:S.slice(-4)})}catch(R){c({submit:R.message})}}:void 0,error:f.code,isSubmitting:h}),e.jsxs("div",{children:[f.submit&&e.jsx(Ca,{children:f.submit}),e.jsx(kg,{type:"submit",disabled:h||!a,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(Sa,{children:[e.jsx(Tr,{onClick:()=>{x(!0),g(null),p(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Tr,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Pn=d.div`
1521
1521
  max-width: 380px;
1522
1522
  width: 380px;
1523
1523
  padding: var(--space-3xl);
1524
1524
  background: var(--color-background);
1525
1525
  border-radius: var(--radius-lg);
1526
1526
  box-shadow: 0 4px 12px var(--color-shadow);
1527
- `,zi=d.div`
1527
+ `,za=d.div`
1528
1528
  text-align: center;
1529
1529
  margin-bottom: var(--space-lg);
1530
1530
  position: relative;
1531
- `,$i=d.h1`
1531
+ `,$a=d.h1`
1532
1532
  font-size: var(--font-lg);
1533
1533
  font-weight: 400;
1534
1534
  color: var(--color-foreground);
1535
1535
  margin-bottom: var(--space-xs);
1536
1536
  margin-top: 0;
1537
- `,Ei=d.p`
1537
+ `,Ea=d.p`
1538
1538
  color: var(--color-secondary-text);
1539
1539
  font-size: var(--font-xs);
1540
1540
  `,Sg=d.div`
@@ -1548,12 +1548,12 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1548
1548
  margin-top: var(--space-2xs);
1549
1549
  `,zg=d(Q)`
1550
1550
  margin-top: var(--space-sm);
1551
- `,Ii=d.div`
1551
+ `,Ia=d.div`
1552
1552
  margin-top: var(--space-lg);
1553
1553
  text-align: center;
1554
1554
  font-size: var(--font-xs);
1555
1555
  color: var(--color-secondary-text);
1556
- `,ao=d.span`
1556
+ `,io=d.span`
1557
1557
  color: var(--color-primary);
1558
1558
  text-decoration: none;
1559
1559
  font-weight: 400;
@@ -1582,7 +1582,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1582
1582
  transform: rotate(360deg);
1583
1583
  }
1584
1584
  }
1585
- `;function Sl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:s}){var B,O,L,X,ee,V,q,te,re;const{deployment:i}=ve(),{navigate:u}=Ge(),[f,c]=a.useState({}),[h,l]=a.useState({}),[p,g]=a.useState("US"),[x,m]=a.useState(!1),[b,$]=a.useState(!1),[z,w]=a.useState(null),[y,k]=a.useState(!1),C=z,_=b,v=async le=>{var oe;$(!0),w(null);try{if(await o(le)){k(!0);let Z=new URLSearchParams(window.location.search).get("redirect_uri");if(Z||(Z=((oe=i==null?void 0:i.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Z&&(i!=null&&i.frontend_host)&&(Z=`https://${i.frontend_host}`),Z){let se;try{se=new URL(Z)}catch{se=new URL(Z,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),u(se.toString())}}}catch(de){const Z=de;throw w(Z),Z}finally{$(!1)}},P=async le=>{var oe;$(!0),w(null);try{if(await n(le)){k(!0);let Z=new URLSearchParams(window.location.search).get("redirect_uri");if(Z||(Z=((oe=i==null?void 0:i.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Z&&(i!=null&&i.frontend_host)&&(Z=`https://${i.frontend_host}`),Z){let se;try{se=new URL(Z)}catch{se=new URL(Z,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),u(se.toString())}}return!0}catch(de){return w(de),!1}finally{$(!1)}};if(y||!t)return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsx($g,{children:e.jsx(kt,{size:32})})]})});const I=t.missing_fields||[],S="Complete Your Profile",T="Please provide the following information to continue",E=i==null?void 0:i.auth_settings,j=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,R=le=>{const{name:oe,value:de}=le.target;c(Z=>({...Z,[oe]:de})),h[oe]&&l(Z=>({...Z,[oe]:""}))},M=()=>{const le={};return I.forEach(oe=>{var se,xe,ue,U,pe;const de=f[oe];let Z=!1;switch(oe){case"first_name":Z=((se=E==null?void 0:E.first_name)==null?void 0:se.enabled)||!1;break;case"last_name":Z=((xe=E==null?void 0:E.last_name)==null?void 0:xe.enabled)||!1;break;case"username":Z=((ue=E==null?void 0:E.username)==null?void 0:ue.enabled)||!1;break;case"phone_number":Z=((U=E==null?void 0:E.phone_number)==null?void 0:U.enabled)||!1;break;case"email_address":Z=((pe=E==null?void 0:E.email_address)==null?void 0:pe.enabled)||!1;break;default:Z=!0}if(Z&&(!de||de.trim()==="")){const K=oe.replace("_"," ").replace(/\b\w/g,H=>H.toUpperCase());le[oe]=`${K} is required`}}),f.username&&I.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(f.username)||(le.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),f.phone_number&&I.includes("phone_number")&&(/^\d{7,15}$/.test(f.phone_number)||(le.phone_number="Phone number must contain 7-15 digits")),f.email&&I.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(f.email)||(le.email_address="Please enter a valid email address")),l(le),Object.keys(le).length===0},F=async le=>{if(le.preventDefault(),!M())return;const oe={...f};f.phone_number&&p&&(oe.phone_country_code=p),await v(oe)},A=le=>{const oe=le.target.value;c(de=>({...de,phone_number:oe})),h.phone_number&&l(de=>({...de,phone_number:""}))};if(j){const le=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",oe=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",de=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(zi,{children:[e.jsx($i,{children:le}),e.jsx(Ei,{children:oe})]}),e.jsxs(dt,{onSubmit:Z=>Z.preventDefault(),noValidate:!0,children:[e.jsx(Tt,{onComplete:P,onResend:async()=>{await s({strategy:de})},error:C==null?void 0:C.message,isSubmitting:_}),C&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:C.message})]}),e.jsxs(Ii,{children:[e.jsx("div",{children:e.jsx(ao,{onClick:()=>m(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(ao,{children:e.jsx(ot,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(zi,{children:[e.jsx($i,{children:S}),e.jsx(Ei,{children:T})]}),e.jsxs(dt,{onSubmit:F,noValidate:!0,children:[(I.includes("first_name")||I.includes("last_name"))&&(((B=E==null?void 0:E.first_name)==null?void 0:B.enabled)||((O=E==null?void 0:E.last_name)==null?void 0:O.enabled))&&e.jsxs(Sg,{$isBothEnabled:!!((L=E==null?void 0:E.first_name)!=null&&L.enabled&&((X=E==null?void 0:E.last_name)!=null&&X.enabled)&&I.includes("first_name")&&I.includes("last_name")),children:[I.includes("first_name")&&((ee=E==null?void 0:E.first_name)==null?void 0:ee.enabled)&&e.jsxs(he,{children:[e.jsxs(ae,{htmlFor:"first_name",children:["First name ",E.first_name.required&&"*"]}),e.jsx(ce,{type:"text",id:"first_name",name:"first_name",value:f.first_name||"",onChange:R,placeholder:"Enter your first name","aria-invalid":!!h.first_name,disabled:_,autoComplete:"given-name"}),h.first_name&&e.jsx(Lt,{children:h.first_name})]}),I.includes("last_name")&&((V=E==null?void 0:E.last_name)==null?void 0:V.enabled)&&e.jsxs(he,{children:[e.jsxs(ae,{htmlFor:"last_name",children:["Last name ",E.last_name.required&&"*"]}),e.jsx(ce,{type:"text",id:"last_name",name:"last_name",value:f.last_name||"",onChange:R,placeholder:"Enter your last name","aria-invalid":!!h.last_name,disabled:_,autoComplete:"family-name"}),h.last_name&&e.jsx(Lt,{children:h.last_name})]})]}),I.includes("username")&&((q=E==null?void 0:E.username)==null?void 0:q.enabled)&&e.jsxs(he,{children:[e.jsxs(ae,{htmlFor:"username",children:["Username ",E.username.required&&"*"]}),e.jsx(ce,{type:"text",id:"username",name:"username",value:f.username||"",onChange:R,placeholder:"Choose a username","aria-invalid":!!h.username,disabled:_,autoComplete:"username"}),h.username&&e.jsx(Lt,{children:h.username})]}),I.includes("phone_number")&&((te=E==null?void 0:E.phone_number)==null?void 0:te.enabled)&&e.jsxs(he,{children:[e.jsxs(ae,{htmlFor:"phone_number",children:["Phone number ",E.phone_number.required&&"*"]}),e.jsx(qr,{value:f.phone_number||"",onChange:A,error:h.phone_number,countryCode:p,setCountryCode:g}),h.phone_number&&e.jsx(Lt,{children:h.phone_number})]}),I.includes("email_address")&&((re=E==null?void 0:E.email_address)==null?void 0:re.enabled)&&e.jsxs(he,{children:[e.jsxs(ae,{htmlFor:"email",children:["Email address ",E.email_address.required&&"*"]}),e.jsx(ce,{type:"email",id:"email",name:"email",value:f.email||"",onChange:R,placeholder:"Enter your email address","aria-invalid":!!h.email_address,disabled:_,autoComplete:"email"}),h.email_address&&e.jsx(Lt,{children:h.email_address})]}),C&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:C.message}),e.jsx(zg,{type:"submit",disabled:_,children:_?"Completing...":"Continue"})]}),e.jsxs(Ii,{children:[r&&e.jsx("div",{children:e.jsx(ao,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(ao,{children:e.jsx(ot,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const Eg=ir`
1585
+ `;function Sl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:s}){var B,O,A,X,te,V,q,re,ne;const{deployment:a}=ve(),{navigate:p}=Ge(),[f,c]=i.useState({}),[h,l]=i.useState({}),[u,g]=i.useState("US"),[v,x]=i.useState(!1),[w,$]=i.useState(!1),[S,k]=i.useState(null),[P,E]=i.useState(!1),z=S,y=w,m=async J=>{var oe;$(!0),k(null);try{if(await o(J)){E(!0);let Z=new URLSearchParams(window.location.search).get("redirect_uri");if(Z||(Z=((oe=a==null?void 0:a.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Z&&(a!=null&&a.frontend_host)&&(Z=`https://${a.frontend_host}`),Z){let ae;try{ae=new URL(Z)}catch{ae=new URL(Z,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&ae.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(ae.toString())}}}catch(de){const Z=de;throw k(Z),Z}finally{$(!1)}},b=async J=>{var oe;$(!0),k(null);try{if(await n(J)){E(!0);let Z=new URLSearchParams(window.location.search).get("redirect_uri");if(Z||(Z=((oe=a==null?void 0:a.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Z&&(a!=null&&a.frontend_host)&&(Z=`https://${a.frontend_host}`),Z){let ae;try{ae=new URL(Z)}catch{ae=new URL(Z,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&ae.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(ae.toString())}}return!0}catch(de){return k(de),!1}finally{$(!1)}};if(P||!t)return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsx($g,{children:e.jsx(kt,{size:32})})]})});const _=t.missing_fields||[],j="Complete Your Profile",T="Please provide the following information to continue",R=a==null?void 0:a.auth_settings,C=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||v,I=J=>{const{name:oe,value:de}=J.target;c(Z=>({...Z,[oe]:de})),h[oe]&&l(Z=>({...Z,[oe]:""}))},M=()=>{const J={};return _.forEach(oe=>{var ae,xe,ue,U,pe;const de=f[oe];let Z=!1;switch(oe){case"first_name":Z=((ae=R==null?void 0:R.first_name)==null?void 0:ae.enabled)||!1;break;case"last_name":Z=((xe=R==null?void 0:R.last_name)==null?void 0:xe.enabled)||!1;break;case"username":Z=((ue=R==null?void 0:R.username)==null?void 0:ue.enabled)||!1;break;case"phone_number":Z=((U=R==null?void 0:R.phone_number)==null?void 0:U.enabled)||!1;break;case"email_address":Z=((pe=R==null?void 0:R.email_address)==null?void 0:pe.enabled)||!1;break;default:Z=!0}if(Z&&(!de||de.trim()==="")){const K=oe.replace("_"," ").replace(/\b\w/g,H=>H.toUpperCase());J[oe]=`${K} is required`}}),f.username&&_.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(f.username)||(J.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),f.phone_number&&_.includes("phone_number")&&(/^\d{7,15}$/.test(f.phone_number)||(J.phone_number="Phone number must contain 7-15 digits")),f.email&&_.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(f.email)||(J.email_address="Please enter a valid email address")),l(J),Object.keys(J).length===0},F=async J=>{if(J.preventDefault(),!M())return;const oe={...f};f.phone_number&&u&&(oe.phone_country_code=u),await m(oe)},L=J=>{const oe=J.target.value;c(de=>({...de,phone_number:oe})),h.phone_number&&l(de=>({...de,phone_number:""}))};if(C){const J=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",oe=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",de=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(za,{children:[e.jsx($a,{children:J}),e.jsx(Ea,{children:oe})]}),e.jsxs(dt,{onSubmit:Z=>Z.preventDefault(),noValidate:!0,children:[e.jsx(Tt,{onComplete:b,onResend:async()=>{await s({strategy:de})},error:z==null?void 0:z.message,isSubmitting:y}),z&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:z.message})]}),e.jsxs(Ia,{children:[e.jsx("div",{children:e.jsx(io,{onClick:()=>x(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(io,{children:e.jsx(ot,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(za,{children:[e.jsx($a,{children:j}),e.jsx(Ea,{children:T})]}),e.jsxs(dt,{onSubmit:F,noValidate:!0,children:[(_.includes("first_name")||_.includes("last_name"))&&(((B=R==null?void 0:R.first_name)==null?void 0:B.enabled)||((O=R==null?void 0:R.last_name)==null?void 0:O.enabled))&&e.jsxs(Sg,{$isBothEnabled:!!((A=R==null?void 0:R.first_name)!=null&&A.enabled&&((X=R==null?void 0:R.last_name)!=null&&X.enabled)&&_.includes("first_name")&&_.includes("last_name")),children:[_.includes("first_name")&&((te=R==null?void 0:R.first_name)==null?void 0:te.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",value:f.first_name||"",onChange:I,placeholder:"Enter your first name","aria-invalid":!!h.first_name,disabled:y,autoComplete:"given-name"}),h.first_name&&e.jsx(Lt,{children:h.first_name})]}),_.includes("last_name")&&((V=R==null?void 0:R.last_name)==null?void 0:V.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",value:f.last_name||"",onChange:I,placeholder:"Enter your last name","aria-invalid":!!h.last_name,disabled:y,autoComplete:"family-name"}),h.last_name&&e.jsx(Lt,{children:h.last_name})]})]}),_.includes("username")&&((q=R==null?void 0:R.username)==null?void 0:q.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),e.jsx(le,{type:"text",id:"username",name:"username",value:f.username||"",onChange:I,placeholder:"Choose a username","aria-invalid":!!h.username,disabled:y,autoComplete:"username"}),h.username&&e.jsx(Lt,{children:h.username})]}),_.includes("phone_number")&&((re=R==null?void 0:R.phone_number)==null?void 0:re.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),e.jsx(qr,{value:f.phone_number||"",onChange:L,error:h.phone_number,countryCode:u,setCountryCode:g}),h.phone_number&&e.jsx(Lt,{children:h.phone_number})]}),_.includes("email_address")&&((ne=R==null?void 0:R.email_address)==null?void 0:ne.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),e.jsx(le,{type:"email",id:"email",name:"email",value:f.email||"",onChange:I,placeholder:"Enter your email address","aria-invalid":!!h.email_address,disabled:y,autoComplete:"email"}),h.email_address&&e.jsx(Lt,{children:h.email_address})]}),z&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:z.message}),e.jsx(zg,{type:"submit",disabled:y,children:y?"Completing...":"Continue"})]}),e.jsxs(Ia,{children:[r&&e.jsx("div",{children:e.jsx(io,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(io,{children:e.jsx(ot,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const Eg=ar`
1586
1586
  from {
1587
1587
  transform: rotate(0deg);
1588
1588
  }
@@ -1596,7 +1596,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1596
1596
  background: var(--color-background);
1597
1597
  border-radius: var(--radius-lg);
1598
1598
  box-shadow: 0 4px 12px var(--color-shadow);
1599
- `,Pi=d.div`
1599
+ `,Pa=d.div`
1600
1600
  display: flex;
1601
1601
  justify-content: center;
1602
1602
  align-items: center;
@@ -1606,17 +1606,17 @@ display: flex;
1606
1606
  animation: ${Eg} 1s linear infinite;
1607
1607
  color: var(--color-primary);
1608
1608
  }
1609
- `,Ri=d.div`
1609
+ `,Ra=d.div`
1610
1610
  text-align: center;
1611
1611
  margin-bottom: var(--space-2xl);
1612
1612
  position: relative;
1613
- `,Ti=d.h1`
1613
+ `,Ta=d.h1`
1614
1614
  font-size: var(--font-lg);
1615
1615
  font-weight: 400;
1616
1616
  color: var(--color-foreground);
1617
1617
  margin-bottom: var(--space-xs);
1618
1618
  margin-top: 0;
1619
- `,Mi=d.p`
1619
+ `,Ma=d.p`
1620
1620
  color: var(--color-secondary-text);
1621
1621
  font-size: var(--font-xs);
1622
1622
  `,Ig=d.div`
@@ -1649,7 +1649,7 @@ position: relative;
1649
1649
  color: var(--color-error);
1650
1650
  margin: 0;
1651
1651
  margin-top: var(--space-2xs);
1652
- `,Oi=d(Q)`
1652
+ `,Oa=d(Q)`
1653
1653
  margin-top: var(--space-lg);
1654
1654
  `,Tn=d.div`
1655
1655
  margin-top: var(--space-lg);
@@ -1691,7 +1691,7 @@ cursor: pointer;
1691
1691
  &:hover {
1692
1692
  color: var(--color-primary-hover);
1693
1693
  }
1694
- `;function Lg(){return e.jsx(Bf,{children:e.jsx(Dg,{})})}function Dg(){var de,Z,se,xe,ue,U,pe,K,H,ne,me,fe;const{deployment:t}=ve(),{navigate:r}=Ge(),{session:o,loading:n}=Ue(),s=((Z=(de=t==null?void 0:t.auth_settings)==null?void 0:de.multi_session_support)==null?void 0:Z.enabled)??!1,{setEmail:i,otpSent:u,setOtpSent:f,showForgotPassword:c,setShowForgotPassword:h,showOtherOptions:l,setShowOtherOptions:p,enabledSocialsProviders:g,firstFactor:x,signInStep:m,setSignInStep:b}=wl(),{loading:$,signIn:z,signinAttempt:w,discardSignInAttempt:y,setSignInAttempt:k}=Br("generic"),{signIn:C}=Br("oauth"),[_,v]=a.useState({email:"",username:"",password:"",phone:""}),[P,I]=a.useState({}),[S,T]=a.useState(!1),[E,j]=a.useState(""),[R,M]=a.useState("US"),[F,A]=a.useState(!1),[B,O]=a.useState(null);a.useEffect(()=>{const W=new URLSearchParams(window.location.search),N=W.get("error"),D=W.get("error_description");if(N==="access_denied"&&D){O(D),W.delete("error"),W.delete("error_description");const Y=W.toString()?`${window.location.pathname}?${W.toString()}`:window.location.pathname;window.history.replaceState({},"",Y)}},[]),a.useEffect(()=>{var W;if(!n&&(o!=null&&o.active_signin)&&!s&&!F){A(!0);let N=new URLSearchParams(window.location.search).get("redirect_uri");N||(N=((W=t==null?void 0:t.ui_settings)==null?void 0:W.after_signin_redirect_url)||null),!N&&(t!=null&&t.frontend_host)&&(N=`https://${t.frontend_host}`),N&&r(N)}},[o,n,s,t,r,F]);const L=W=>{let{name:N,value:D}=W.target;N==="phone"?D=D.replace(/[^0-9]/g,""):N==="email"&&(i(D),D=D.toLowerCase()),v(Y=>({...Y,[N]:D})),I(Y=>({...Y,[N]:""}))},X=()=>{v({email:"",username:"",password:"",phone:""}),I({}),M("US"),b("identifier")},ee=async W=>{if(!W){I({email:"Email address is required"});return}T(!0),I({});try{const N=await z.identify(W);if(N.strategy==="sso"&&N.connection_id){const Y=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,ie=await z.initEnterpriseSso(N.connection_id,Y);if(ie&&ie.sso_url){A(!0),window.location.href=ie.sso_url;return}}else if(N.strategy==="social"&&N.provider){const D=g.find(Y=>Y.provider===N.provider);if(D){const ie=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:J}=await C.create({provider:D.provider,redirectUri:ie});if(J&&typeof J=="object"&&"oauth_url"in J){A(!0),window.location.href=J.oauth_url;return}}else b("password")}else b("password")}catch(N){I({submit:N.message})}finally{F||T(!1)}},V=async W=>{if(W.preventDefault(),$||S)return;y();const N={};if(m==="identifier"&&x==="email_password"){if(!_.email){I({email:"Email address is required"});return}await ee(_.email);return}if(x==="email_password"?(_.email||(N.email="Email address is required"),_.password||(N.password="Password is required")):x==="username_password"?(_.username||(N.username="Username is required"),_.password||(N.password="Password is required")):x==="email_otp"||x==="email_magic_link"?_.email||(N.email="Email address is required"):x==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(N.phone="Phone number must contain 7-15 digits"):N.phone="Phone number is required"),I(N),Object.keys(N).length>0)return;let D="";switch(x){case"email_password":D="plain_email";break;case"username_password":D="plain_username";break;case"email_otp":D="email_otp";break;case"email_magic_link":D="magic_link";break;case"phone_otp":D="phone_otp";break}T(!0);try{const Y={..._,strategy:D};x==="phone_otp"&&R&&(Y.phone_country_code=R),await z.create(Y)}catch(Y){I({submit:Y.message}),T(!1)}},q=async W=>{if(W.preventDefault(),$||S)return;const N={};if(!E){N.otp="OTP code is required",I(N);return}T(!0),I({});try{await z.completeVerification(E),f(!1),j("")}catch(D){I({otp:D.message||"Verification failed"})}finally{T(!1)}},te=async W=>{if(!($||S)){T(!0);try{const D=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Y}=await C.create({provider:W.provider,redirectUri:D});Y&&typeof Y=="object"&&"oauth_url"in Y&&(window.location.href=Y.oauth_url)}catch(N){I({submit:N.message})}finally{T(!1)}}},re=a.useRef(!1);if(a.useEffect(()=>{if(n)return;const W=new URLSearchParams(window.location.search),N=W.get("impersonation_token");if(N&&!w&&!$&&!re.current){re.current=!0,W.delete("impersonation_token");const Y=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",Y),(async()=>{try{T(!0),await z.create({strategy:"impersonation",token:N})}catch(J){I({submit:J.message}),T(!1),re.current=!1}})();return}const D=W.get("signin_attempt_id");if(D&&(o!=null&&o.signin_attempts)&&!w){const Y=o.signin_attempts.find(ie=>ie.id===D);if(Y){k(Y),W.delete("signin_attempt_id");const ie=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",ie)}}},[o,n,w,k,$]),a.useEffect(()=>{var Y;if(!w)return;if(w.completed){A(!0);let ie=new URLSearchParams(window.location.search).get("redirect_uri");if(ie||(ie=((Y=t==null?void 0:t.ui_settings)==null?void 0:Y.after_signin_redirect_url)||null),!ie&&(t!=null&&t.frontend_host)&&(ie=`https://${t.frontend_host}`),ie){let J;try{J=new URL(ie)}catch{J=new URL(ie,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&J.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(J.toString())}return}if(!z||u)return;const N={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[w.current_step];if(!N)return;(async()=>{try{await z.prepareVerification({strategy:N}),f(!0)}catch(ie){console.error("Failed to prepare verification:",ie),I({submit:"Failed to send verification. Please try again."})}finally{T(!1)}})()},[w,z,u,f,r,t]),a.useEffect(()=>{},[]),l)return e.jsx(Xf,{onBack:()=>p(!1)});if(c)return e.jsx(Hf,{onBack:()=>h(!1)});if((w==null?void 0:w.current_step)==="verify_second_factor")return e.jsx(Cl,{attempt:w,completeVerification:z.completeVerification,prepareVerification:z.prepareVerification,onBack:()=>{y(),X(),f(!1)}});if((w==null?void 0:w.current_step)==="complete_profile")return e.jsx(Sl,{attempt:w,completeProfile:z.completeProfile,completeVerification:z.completeVerification,prepareVerification:z.prepareVerification,onBack:()=>{y(),X(),f(!1)}});if(n)return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Pi,{children:e.jsx(kt,{size:32})})]})});if(F)return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Pi,{children:e.jsx(kt,{size:32})})]})});const oe=(w==null?void 0:w.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(w.current_step)&&u;return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),oe?e.jsx(e.Fragment,{children:e.jsxs(Ri,{children:[e.jsx(Ti,{children:x==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Mi,{children:x==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:x==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(Ri,{children:[e.jsx(Ti,{children:"Sign in to your account"}),e.jsxs(Mi,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),B&&e.jsxs(Tg,{children:[e.jsx(Mg,{children:"Access Denied"}),e.jsx(Og,{children:B}),e.jsx(Ag,{onClick:()=>O(null),children:"Try again"})]}),oe?x==="email_magic_link"?e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{f(!1),y(),X()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:q,noValidate:!0,children:[e.jsx(Tt,{onComplete:async W=>{if(j(W),W&&W.length===6){T(!0),I({});try{await z.completeVerification(W),f(!1)}catch(N){I({otp:N.message||"Verification failed"})}finally{T(!1)}}},onResend:async()=>{const W=x==="email_otp"?"email_otp":"phone_otp";await z.prepareVerification({strategy:W})},error:P.otp,isSubmitting:S}),e.jsx(Oi,{type:"submit",disabled:S||$||!E,style:{margin:0},children:S?"Verifying...":`Continue to ${(fe=t==null?void 0:t.ui_settings)==null?void 0:fe.app_name}`})]}),e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{f(!1),y(),X()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Es,{connections:g,callback:te}),e.jsx(Ig,{children:e.jsx(Pg,{children:"or"})})]}),e.jsxs(dt,{onSubmit:V,noValidate:!0,children:[(x==="email_password"||x==="email_otp"||x==="email_magic_link")&&((xe=(se=t==null?void 0:t.auth_settings)==null?void 0:se.email_address)==null?void 0:xe.enabled)&&e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"email",children:"Email address"}),e.jsx(ce,{type:"email",id:"email",name:"email",value:_.email,onChange:L,placeholder:"Enter your email address","aria-invalid":!!P.email}),P.email&&e.jsx(Mr,{children:P.email})]}),x==="username_password"&&((U=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.username)==null?void 0:U.enabled)&&e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"username",children:"Username"}),e.jsx(ce,{type:"text",id:"username",name:"username",value:_.username,onChange:L,placeholder:"Enter your username","aria-invalid":!!P.username}),P.username&&e.jsx(Mr,{children:P.username})]}),x==="phone_otp"&&((K=(pe=t==null?void 0:t.auth_settings)==null?void 0:pe.phone_number)==null?void 0:K.enabled)&&e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"phone",children:"Phone number"}),e.jsx(qr,{value:_.phone,onChange:L,error:P.phone,countryCode:R,setCountryCode:M}),P.phone&&e.jsx(Mr,{children:P.phone})]}),m==="password"&&(x==="email_password"||x==="username_password")&&((ne=(H=t==null?void 0:t.auth_settings)==null?void 0:H.password)==null?void 0:ne.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ae,{htmlFor:"password",children:"Password"}),e.jsx(Dt,{style:{fontSize:"12px"},onClick:()=>h(!0),children:"Forgot password?"})]}),e.jsx(Rg,{children:e.jsx(ce,{type:"password",id:"password",name:"password",value:_.password,onChange:L,placeholder:"Enter your password","aria-invalid":!!P.password})}),P.password&&e.jsx(Mr,{children:P.password})]}),e.jsxs("div",{children:[P.submit&&e.jsx(Mr,{children:P.submit}),e.jsx(Oi,{type:"submit",disabled:S||$,children:S?e.jsxs(e.Fragment,{children:[e.jsx(kt,{size:16,style:{animation:"spin 1s linear infinite",marginRight:"8px"}}),m==="identifier"?"Checking...":"Signing in..."]}):m==="identifier"?"Continue":"Sign in"})]}),e.jsx(Dt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>p(!0),children:"Use other methods"})]}),e.jsxs(Tn,{children:["Don't have an account?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:`${(me=t.ui_settings)==null?void 0:me.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Ai=d.div`
1694
+ `;function Lg(){return e.jsx(Bf,{children:e.jsx(Dg,{})})}function Dg(){var de,Z,ae,xe,ue,U,pe,K,H,se,me,fe;const{deployment:t}=ve(),{navigate:r}=Ge(),{session:o,loading:n}=Ue(),s=((Z=(de=t==null?void 0:t.auth_settings)==null?void 0:de.multi_session_support)==null?void 0:Z.enabled)??!1,{setEmail:a,otpSent:p,setOtpSent:f,showForgotPassword:c,setShowForgotPassword:h,showOtherOptions:l,setShowOtherOptions:u,enabledSocialsProviders:g,firstFactor:v,signInStep:x,setSignInStep:w}=wl(),{loading:$,signIn:S,signinAttempt:k,discardSignInAttempt:P,setSignInAttempt:E}=Br("generic"),{signIn:z}=Br("oauth"),[y,m]=i.useState({email:"",username:"",password:"",phone:""}),[b,_]=i.useState({}),[j,T]=i.useState(!1),[R,C]=i.useState(""),[I,M]=i.useState("US"),[F,L]=i.useState(!1),[B,O]=i.useState(null);i.useEffect(()=>{const W=new URLSearchParams(window.location.search),N=W.get("error"),D=W.get("error_description");if(N==="access_denied"&&D){O(D),W.delete("error"),W.delete("error_description");const Y=W.toString()?`${window.location.pathname}?${W.toString()}`:window.location.pathname;window.history.replaceState({},"",Y)}},[]),i.useEffect(()=>{var W;if(!n&&(o!=null&&o.active_signin)&&!s&&!F){L(!0);let N=new URLSearchParams(window.location.search).get("redirect_uri");N||(N=((W=t==null?void 0:t.ui_settings)==null?void 0:W.after_signin_redirect_url)||null),!N&&(t!=null&&t.frontend_host)&&(N=`https://${t.frontend_host}`),N&&r(N)}},[o,n,s,t,r,F]);const A=W=>{let{name:N,value:D}=W.target;N==="phone"?D=D.replace(/[^0-9]/g,""):N==="email"&&(a(D),D=D.toLowerCase()),m(Y=>({...Y,[N]:D})),_(Y=>({...Y,[N]:""}))},X=()=>{m({email:"",username:"",password:"",phone:""}),_({}),M("US"),w("identifier")},te=async W=>{if(!W){_({email:"Email address is required"});return}T(!0),_({});try{const N=await S.identify(W);if(N.strategy==="sso"&&N.connection_id){const Y=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,ie=await S.initEnterpriseSso(N.connection_id,Y);if(ie&&ie.sso_url){L(!0),window.location.href=ie.sso_url;return}}else if(N.strategy==="social"&&N.provider){const D=g.find(Y=>Y.provider===N.provider);if(D){const ie=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:ee}=await z.create({provider:D.provider,redirectUri:ie});if(ee&&typeof ee=="object"&&"oauth_url"in ee){L(!0),window.location.href=ee.oauth_url;return}}else w("password")}else w("password")}catch(N){_({submit:N.message})}finally{F||T(!1)}},V=async W=>{if(W.preventDefault(),$||j)return;P();const N={};if(x==="identifier"&&v==="email_password"){if(!y.email){_({email:"Email address is required"});return}await te(y.email);return}if(v==="email_password"?(y.email||(N.email="Email address is required"),y.password||(N.password="Password is required")):v==="username_password"?(y.username||(N.username="Username is required"),y.password||(N.password="Password is required")):v==="email_otp"||v==="email_magic_link"?y.email||(N.email="Email address is required"):v==="phone_otp"&&(y.phone?/^\d{7,15}$/.test(y.phone)||(N.phone="Phone number must contain 7-15 digits"):N.phone="Phone number is required"),_(N),Object.keys(N).length>0)return;let D="";switch(v){case"email_password":D="plain_email";break;case"username_password":D="plain_username";break;case"email_otp":D="email_otp";break;case"email_magic_link":D="magic_link";break;case"phone_otp":D="phone_otp";break}T(!0);try{const Y={...y,strategy:D};v==="phone_otp"&&I&&(Y.phone_country_code=I),await S.create(Y)}catch(Y){_({submit:Y.message}),T(!1)}},q=async W=>{if(W.preventDefault(),$||j)return;const N={};if(!R){N.otp="OTP code is required",_(N);return}T(!0),_({});try{await S.completeVerification(R),f(!1),C("")}catch(D){_({otp:D.message||"Verification failed"})}finally{T(!1)}},re=async W=>{if(!($||j)){T(!0);try{const D=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Y}=await z.create({provider:W.provider,redirectUri:D});Y&&typeof Y=="object"&&"oauth_url"in Y&&(window.location.href=Y.oauth_url)}catch(N){_({submit:N.message})}finally{T(!1)}}},ne=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const W=new URLSearchParams(window.location.search),N=W.get("impersonation_token");if(N&&!k&&!$&&!ne.current){ne.current=!0,W.delete("impersonation_token");const Y=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",Y),(async()=>{try{T(!0),await S.create({strategy:"impersonation",token:N})}catch(ee){_({submit:ee.message}),T(!1),ne.current=!1}})();return}const D=W.get("signin_attempt_id");if(D&&(o!=null&&o.signin_attempts)&&!k){const Y=o.signin_attempts.find(ie=>ie.id===D);if(Y){E(Y),W.delete("signin_attempt_id");const ie=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",ie)}}},[o,n,k,E,$]),i.useEffect(()=>{var Y;if(!k)return;if(k.completed){L(!0);let ie=new URLSearchParams(window.location.search).get("redirect_uri");if(ie||(ie=((Y=t==null?void 0:t.ui_settings)==null?void 0:Y.after_signin_redirect_url)||null),!ie&&(t!=null&&t.frontend_host)&&(ie=`https://${t.frontend_host}`),ie){let ee;try{ee=new URL(ie)}catch{ee=new URL(ie,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&ee.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(ee.toString())}return}if(!S||p)return;const N={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(!N)return;(async()=>{try{await S.prepareVerification({strategy:N}),f(!0)}catch(ie){console.error("Failed to prepare verification:",ie),_({submit:"Failed to send verification. Please try again."})}finally{T(!1)}})()},[k,S,p,f,r,t]),i.useEffect(()=>{},[]),l)return e.jsx(Xf,{onBack:()=>u(!1)});if(c)return e.jsx(Hf,{onBack:()=>h(!1)});if((k==null?void 0:k.current_step)==="verify_second_factor")return e.jsx(Cl,{attempt:k,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{P(),X(),f(!1)}});if((k==null?void 0:k.current_step)==="complete_profile")return e.jsx(Sl,{attempt:k,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{P(),X(),f(!1)}});if(n)return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Pa,{children:e.jsx(kt,{size:32})})]})});if(F)return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Pa,{children:e.jsx(kt,{size:32})})]})});const oe=(k==null?void 0:k.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(k.current_step)&&p;return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),oe?e.jsx(e.Fragment,{children:e.jsxs(Ra,{children:[e.jsx(Ta,{children:v==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Ma,{children:v==="email_magic_link"?`If ${y.email} exists in our records, you will receive a magic link. Click the link to sign in.`:v==="phone_otp"?`If ${y.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${y.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(Ra,{children:[e.jsx(Ta,{children:"Sign in to your account"}),e.jsxs(Ma,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),B&&e.jsxs(Tg,{children:[e.jsx(Mg,{children:"Access Denied"}),e.jsx(Og,{children:B}),e.jsx(Ag,{onClick:()=>O(null),children:"Try again"})]}),oe?v==="email_magic_link"?e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{f(!1),P(),X()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:q,noValidate:!0,children:[e.jsx(Tt,{onComplete:async W=>{if(C(W),W&&W.length===6){T(!0),_({});try{await S.completeVerification(W),f(!1)}catch(N){_({otp:N.message||"Verification failed"})}finally{T(!1)}}},onResend:async()=>{const W=v==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:W})},error:b.otp,isSubmitting:j}),e.jsx(Oa,{type:"submit",disabled:j||$||!R,style:{margin:0},children:j?"Verifying...":`Continue to ${(fe=t==null?void 0:t.ui_settings)==null?void 0:fe.app_name}`})]}),e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{f(!1),P(),X()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Es,{connections:g,callback:re}),e.jsx(Ig,{children:e.jsx(Pg,{children:"or"})})]}),e.jsxs(dt,{onSubmit:V,noValidate:!0,children:[(v==="email_password"||v==="email_otp"||v==="email_magic_link")&&((xe=(ae=t==null?void 0:t.auth_settings)==null?void 0:ae.email_address)==null?void 0:xe.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"email",children:"Email address"}),e.jsx(le,{type:"email",id:"email",name:"email",value:y.email,onChange:A,placeholder:"Enter your email address","aria-invalid":!!b.email}),b.email&&e.jsx(Mr,{children:b.email})]}),v==="username_password"&&((U=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.username)==null?void 0:U.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"username",children:"Username"}),e.jsx(le,{type:"text",id:"username",name:"username",value:y.username,onChange:A,placeholder:"Enter your username","aria-invalid":!!b.username}),b.username&&e.jsx(Mr,{children:b.username})]}),v==="phone_otp"&&((K=(pe=t==null?void 0:t.auth_settings)==null?void 0:pe.phone_number)==null?void 0:K.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"phone",children:"Phone number"}),e.jsx(qr,{value:y.phone,onChange:A,error:b.phone,countryCode:I,setCountryCode:M}),b.phone&&e.jsx(Mr,{children:b.phone})]}),x==="password"&&(v==="email_password"||v==="username_password")&&((se=(H=t==null?void 0:t.auth_settings)==null?void 0:H.password)==null?void 0:se.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ce,{htmlFor:"password",children:"Password"}),e.jsx(Dt,{style:{fontSize:"12px"},onClick:()=>h(!0),children:"Forgot password?"})]}),e.jsx(Rg,{children:e.jsx(le,{type:"password",id:"password",name:"password",value:y.password,onChange:A,placeholder:"Enter your password","aria-invalid":!!b.password})}),b.password&&e.jsx(Mr,{children:b.password})]}),e.jsxs("div",{children:[b.submit&&e.jsx(Mr,{children:b.submit}),e.jsx(Oa,{type:"submit",disabled:j||$,children:j?e.jsxs(e.Fragment,{children:[e.jsx(kt,{size:16,style:{animation:"spin 1s linear infinite",marginRight:"8px"}}),x==="identifier"?"Checking...":"Signing in..."]}):x==="identifier"?"Continue":"Sign in"})]}),e.jsx(Dt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>u(!0),children:"Use other methods"})]}),e.jsxs(Tn,{children:["Don't have an account?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:`${(me=t.ui_settings)==null?void 0:me.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Aa=d.div`
1695
1695
  max-width: 380px;
1696
1696
  width: 380px;
1697
1697
  padding: var(--space-3xl);
@@ -1792,7 +1792,7 @@ cursor: pointer;
1792
1792
  color: var(--color-primary);
1793
1793
  text-decoration: none;
1794
1794
  cursor: pointer;
1795
- `;function Xg(){var $,z,w,y,k,C,_,v,P,I,S,T;const{deployment:t}=ve(),{loading:r,joinWaitlist:o}=yc(),[n,s]=a.useState({first_name:"",last_name:"",email:""}),[i,u]=a.useState(!1),[f,c]=a.useState(!1),[h,l]=a.useState(null),p=E=>{if(h)return h.message},g=t==null?void 0:t.auth_settings,x=!!(($=g==null?void 0:g.first_name)!=null&&$.enabled&&((z=g==null?void 0:g.last_name)!=null&&z.enabled)),m=E=>{const{name:j,value:R}=E.target;s(M=>({...M,[j]:R}))},b=async E=>{if(E.preventDefault(),!!g){c(!0),l(null);try{(await o(n)).data&&u(!0)}catch(j){l(j)}finally{c(!1)}}};return i?e.jsx(ge,{children:e.jsx(Ai,{children:e.jsxs(Gg,{children:[e.jsx(Hg,{children:e.jsx(Ve,{size:32})}),e.jsx(qg,{children:"You're on the waitlist!"}),e.jsxs(Yg,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(ge,{children:e.jsxs(Ai,{children:[e.jsx(Pe,{}),e.jsxs(Ng,{children:[e.jsx(Fg,{children:"Join the waitlist"}),e.jsx(Bg,{children:"Be the first to know when we launch!"})]}),e.jsxs(Ug,{onSubmit:b,noValidate:!0,children:[(((w=g==null?void 0:g.first_name)==null?void 0:w.enabled)||((y=g==null?void 0:g.last_name)==null?void 0:y.enabled))&&e.jsxs(Wg,{$isBothEnabled:x,children:[((k=g==null?void 0:g.first_name)==null?void 0:k.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"first_name",children:["First name",((C=g==null?void 0:g.first_name)==null?void 0:C.required)&&e.jsx(An,{children:"*"})]}),e.jsx(ce,{type:"text",id:"first_name",name:"first_name",required:(_=g==null?void 0:g.first_name)==null?void 0:_.required,minLength:2,maxLength:50,value:n.first_name,onChange:m,placeholder:"First name","aria-invalid":!!p()}),p()&&e.jsx(co,{children:p()})]}),((v=g==null?void 0:g.last_name)==null?void 0:v.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"last_name",children:["Last name",((P=g==null?void 0:g.last_name)==null?void 0:P.required)&&e.jsx(An,{children:"*"})]}),e.jsx(ce,{type:"text",id:"last_name",name:"last_name",required:(I=g==null?void 0:g.last_name)==null?void 0:I.required,minLength:2,maxLength:50,value:n.last_name,onChange:m,placeholder:"Last name","aria-invalid":!!p()}),p()&&e.jsx(co,{children:p()})]})]}),e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"email",children:["Email address",((S=g==null?void 0:g.email_address)==null?void 0:S.required)&&e.jsx(An,{children:"*"})]}),e.jsx(ce,{type:"email",id:"email",name:"email",required:(T=g==null?void 0:g.email_address)==null?void 0:T.required,value:n.email,onChange:m,placeholder:"Enter your email address","aria-invalid":!!p()}),p()&&e.jsx(co,{children:p()})]}),p()&&e.jsx(co,{children:p()}),e.jsx(Vg,{type:"submit",$primary:!0,disabled:f||r,children:f||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(Zg,{children:e.jsxs(Kg,{children:["Need assistance? ",e.jsx(Qg,{href:"/contact",children:"Get help"})]})})]})})}const lo=d.div`
1795
+ `;function Xg(){var $,S,k,P,E,z,y,m,b,_,j,T;const{deployment:t}=ve(),{loading:r,joinWaitlist:o}=yc(),[n,s]=i.useState({first_name:"",last_name:"",email:""}),[a,p]=i.useState(!1),[f,c]=i.useState(!1),[h,l]=i.useState(null),u=R=>{if(h)return h.message},g=t==null?void 0:t.auth_settings,v=!!(($=g==null?void 0:g.first_name)!=null&&$.enabled&&((S=g==null?void 0:g.last_name)!=null&&S.enabled)),x=R=>{const{name:C,value:I}=R.target;s(M=>({...M,[C]:I}))},w=async R=>{if(R.preventDefault(),!!g){c(!0),l(null);try{(await o(n)).data&&p(!0)}catch(C){l(C)}finally{c(!1)}}};return a?e.jsx(ge,{children:e.jsx(Aa,{children:e.jsxs(Gg,{children:[e.jsx(Hg,{children:e.jsx(Ve,{size:32})}),e.jsx(qg,{children:"You're on the waitlist!"}),e.jsxs(Yg,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(ge,{children:e.jsxs(Aa,{children:[e.jsx(Pe,{}),e.jsxs(Ng,{children:[e.jsx(Fg,{children:"Join the waitlist"}),e.jsx(Bg,{children:"Be the first to know when we launch!"})]}),e.jsxs(Ug,{onSubmit:w,noValidate:!0,children:[(((k=g==null?void 0:g.first_name)==null?void 0:k.enabled)||((P=g==null?void 0:g.last_name)==null?void 0:P.enabled))&&e.jsxs(Wg,{$isBothEnabled:v,children:[((E=g==null?void 0:g.first_name)==null?void 0:E.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"first_name",children:["First name",((z=g==null?void 0:g.first_name)==null?void 0:z.required)&&e.jsx(An,{children:"*"})]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",required:(y=g==null?void 0:g.first_name)==null?void 0:y.required,minLength:2,maxLength:50,value:n.first_name,onChange:x,placeholder:"First name","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]}),((m=g==null?void 0:g.last_name)==null?void 0:m.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"last_name",children:["Last name",((b=g==null?void 0:g.last_name)==null?void 0:b.required)&&e.jsx(An,{children:"*"})]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",required:(_=g==null?void 0:g.last_name)==null?void 0:_.required,minLength:2,maxLength:50,value:n.last_name,onChange:x,placeholder:"Last name","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]})]}),e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"email",children:["Email address",((j=g==null?void 0:g.email_address)==null?void 0:j.required)&&e.jsx(An,{children:"*"})]}),e.jsx(le,{type:"email",id:"email",name:"email",required:(T=g==null?void 0:g.email_address)==null?void 0:T.required,value:n.email,onChange:x,placeholder:"Enter your email address","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]}),u()&&e.jsx(co,{children:u()}),e.jsx(Vg,{type:"submit",$primary:!0,disabled:f||r,children:f||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(Zg,{children:e.jsxs(Kg,{children:["Need assistance? ",e.jsx(Qg,{href:"/contact",children:"Get help"})]})})]})})}const lo=d.div`
1796
1796
  max-width: 380px;
1797
1797
  width: 380px;
1798
1798
  padding: var(--space-3xl);
@@ -1827,7 +1827,7 @@ cursor: pointer;
1827
1827
  margin: 0 auto var(--space-lg) auto;
1828
1828
  color: var(--color-error);
1829
1829
  font-size: var(--font-xl);
1830
- `,Li=d.div`
1830
+ `,La=d.div`
1831
1831
  width: calc(var(--space-3xl) * 2);
1832
1832
  height: calc(var(--space-3xl) * 2);
1833
1833
  border: 3px solid var(--color-border);
@@ -1879,7 +1879,7 @@ cursor: pointer;
1879
1879
  color: var(--color-primary-hover);
1880
1880
  text-decoration: underline;
1881
1881
  }
1882
- `;function om(){const{deployment:t}=ve(),{navigate:r}=Ge(),{error:o,session:n,processed:s,signinAttempt:i,redirectUri:u,loading:f}=wc(),c=()=>{window.location.reload()},h=()=>{var p;const l=((p=t==null?void 0:t.ui_settings)==null?void 0:p.sign_in_page_url)||"/sign-in";r(l)};if(a.useEffect(()=>{var l,p;if(!(!s||f)){if(i&&!i.completed){const g=(l=t==null?void 0:t.ui_settings)==null?void 0:l.sign_in_page_url;if(g){const x=new URL(g,window.location.origin);x.searchParams.set("signin_attempt_id",i.id),u&&x.searchParams.set("redirect_uri",u),r(x.toString())}return}if(i!=null&&i.completed){const g=u||((p=t==null?void 0:t.ui_settings)==null?void 0:p.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let x;try{x=new URL(g)}catch{x=new URL(g,window.location.origin)}x&&((t==null?void 0:t.mode)==="staging"&&x.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(x.toString()))}}},[n,s,f,u,t,i,r]),a.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var p;const l=((p=t==null?void 0:t.ui_settings)==null?void 0:p.sign_in_page_url)||(t==null?void 0:t.frontend_host);l&&r(l)},2e3)},[o,t,r]),f&&!s)return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Completing sign in"}),e.jsx(ho,{children:"Please wait while we authenticate you"})]}),e.jsxs(fo,{children:[e.jsx(Li,{}),e.jsx(go,{children:"Verifying your credentials..."}),e.jsx(mo,{children:"This will only take a moment."})]})]})});if(n&&s&&!o)return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Success!"}),e.jsx(ho,{children:"Authentication completed successfully"})]}),e.jsxs(fo,{children:[e.jsx(em,{children:"✓"}),e.jsx(go,{children:"Redirecting you now..."}),e.jsx(mo,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const l=o.message.includes("No OAuth callback data found");return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Something went wrong"}),e.jsx(ho,{children:"We couldn't complete your sign in"})]}),e.jsxs(fo,{children:[e.jsx(Jg,{children:"✗"}),e.jsx(go,{children:"Authentication Failed"}),e.jsx(mo,{children:o.message||"An unexpected error occurred during authentication."}),!l&&e.jsx(Q,{onClick:c,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!l&&e.jsx(tm,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(rm,{onClick:h,children:"Return to sign in"})]})})]})})}return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Completing sign in"}),e.jsx(ho,{children:"Please wait while we authenticate you"})]}),e.jsxs(fo,{children:[e.jsx(Li,{}),e.jsx(go,{children:"Verifying your credentials..."}),e.jsx(mo,{children:"This will only take a moment."})]})]})})}const nm=d.div`
1882
+ `;function om(){const{deployment:t}=ve(),{navigate:r}=Ge(),{error:o,session:n,processed:s,signinAttempt:a,redirectUri:p,loading:f}=wc(),c=()=>{window.location.reload()},h=()=>{var u;const l=((u=t==null?void 0:t.ui_settings)==null?void 0:u.sign_in_page_url)||"/sign-in";r(l)};if(i.useEffect(()=>{var l,u;if(!(!s||f)){if(a&&!a.completed){const g=(l=t==null?void 0:t.ui_settings)==null?void 0:l.sign_in_page_url;if(g){const v=new URL(g,window.location.origin);v.searchParams.set("signin_attempt_id",a.id),p&&v.searchParams.set("redirect_uri",p),r(v.toString())}return}if(a!=null&&a.completed){const g=p||((u=t==null?void 0:t.ui_settings)==null?void 0:u.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let v;try{v=new URL(g)}catch{v=new URL(g,window.location.origin)}v&&((t==null?void 0:t.mode)==="staging"&&v.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(v.toString()))}}},[n,s,f,p,t,a,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var u;const l=((u=t==null?void 0:t.ui_settings)==null?void 0:u.sign_in_page_url)||(t==null?void 0:t.frontend_host);l&&r(l)},2e3)},[o,t,r]),f&&!s)return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Completing sign in"}),e.jsx(ho,{children:"Please wait while we authenticate you"})]}),e.jsxs(fo,{children:[e.jsx(La,{}),e.jsx(go,{children:"Verifying your credentials..."}),e.jsx(mo,{children:"This will only take a moment."})]})]})});if(n&&s&&!o)return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Success!"}),e.jsx(ho,{children:"Authentication completed successfully"})]}),e.jsxs(fo,{children:[e.jsx(em,{children:"✓"}),e.jsx(go,{children:"Redirecting you now..."}),e.jsx(mo,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const l=o.message.includes("No OAuth callback data found");return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Something went wrong"}),e.jsx(ho,{children:"We couldn't complete your sign in"})]}),e.jsxs(fo,{children:[e.jsx(Jg,{children:"✗"}),e.jsx(go,{children:"Authentication Failed"}),e.jsx(mo,{children:o.message||"An unexpected error occurred during authentication."}),!l&&e.jsx(Q,{onClick:c,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!l&&e.jsx(tm,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(rm,{onClick:h,children:"Return to sign in"})]})})]})})}return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Completing sign in"}),e.jsx(ho,{children:"Please wait while we authenticate you"})]}),e.jsxs(fo,{children:[e.jsx(La,{}),e.jsx(go,{children:"Verifying your credentials..."}),e.jsx(mo,{children:"This will only take a moment."})]})]})})}const nm=d.div`
1883
1883
  max-width: 380px;
1884
1884
  width: 380px;
1885
1885
  padding: var(--space-3xl);
@@ -1889,13 +1889,13 @@ cursor: pointer;
1889
1889
  `,sm=d.div`
1890
1890
  text-align: center;
1891
1891
  position: relative;
1892
- `,im=d.h1`
1892
+ `,am=d.h1`
1893
1893
  font-size: var(--font-lg);
1894
1894
  font-weight: 400;
1895
1895
  color: var(--color-foreground);
1896
1896
  margin-bottom: var(--space-xs);
1897
1897
  margin-top: 0;
1898
- `,am=d.p`
1898
+ `,im=d.p`
1899
1899
  color: var(--color-secondary-text);
1900
1900
  font-size: var(--font-xs);
1901
1901
  margin: 0;
@@ -1944,7 +1944,7 @@ cursor: pointer;
1944
1944
  `,Ln=d.p`
1945
1945
  font-size: var(--font-xs);
1946
1946
  color: var(--color-secondary-text);
1947
- `;function pm({onSuccess:t,onError:r}={}){const[o,n]=a.useState("loading"),[s,i]=a.useState(""),{token:u,attempt:f,redirectUri:c}=_c(),{verifyMagicLink:h}=jc(),{navigate:l}=Ge(),{deployment:p}=ve(),g=a.useRef(!1);a.useEffect(()=>{(async()=>{if(!g.current){if(!u||!f){n("error"),i("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}g.current=!0,n("loading"),i("Please wait while we verify your magic link.");try{await h({token:u,attempt:f,redirectUri:c}),n("success"),i("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var $;let b=c;if(b||(b=($=p==null?void 0:p.ui_settings)==null?void 0:$.after_signin_redirect_url),!b&&(p!=null&&p.frontend_host)&&(b=`https://${p.frontend_host}`),b){const z=new URL(b);(p==null?void 0:p.mode)==="staging"&&z.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),l(z.toString())}},2e3)}catch(b){n("error"),i("The magic link may have expired or already been used. Please try signing in again."),r==null||r(b.message)}}})()},[u,f]);const x=()=>{var m;(m=p==null?void 0:p.ui_settings)!=null&&m.sign_in_page_url&&l(p.ui_settings.sign_in_page_url)};return e.jsx(ge,{children:e.jsxs(nm,{children:[e.jsxs(sm,{children:[e.jsx(im,{children:"Magic Link Verification"}),e.jsx(am,{children:"Verifying your magic link"})]}),e.jsxs(cm,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(um,{}),e.jsx(Ln,{children:s})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(lm,{children:"✓"}),e.jsx(Ln,{children:s})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(dm,{children:"✗"}),e.jsx(Ln,{children:s}),e.jsx(Q,{onClick:x,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function hm(t){var n,s;return t?((n=t.signin_attempts)==null?void 0:n.find(i=>i.requires_completion&&!i.completed))?!0:!!((s=t.signup_attempts)==null?void 0:s.find(i=>{var u,f;return((u=i.missing_fields)==null?void 0:u.length)>0||((f=i.remaining_steps)==null?void 0:f.length)>0&&!i.completed})):!1}function fm(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Nt=d.div`
1947
+ `;function pm({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[s,a]=i.useState(""),{token:p,attempt:f,redirectUri:c}=_c(),{verifyMagicLink:h}=jc(),{navigate:l}=Ge(),{deployment:u}=ve(),g=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!g.current){if(!p||!f){n("error"),a("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}g.current=!0,n("loading"),a("Please wait while we verify your magic link.");try{await h({token:p,attempt:f,redirectUri:c}),n("success"),a("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var $;let w=c;if(w||(w=($=u==null?void 0:u.ui_settings)==null?void 0:$.after_signin_redirect_url),!w&&(u!=null&&u.frontend_host)&&(w=`https://${u.frontend_host}`),w){const S=new URL(w);(u==null?void 0:u.mode)==="staging"&&S.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),l(S.toString())}},2e3)}catch(w){n("error"),a("The magic link may have expired or already been used. Please try signing in again."),r==null||r(w.message)}}})()},[p,f]);const v=()=>{var x;(x=u==null?void 0:u.ui_settings)!=null&&x.sign_in_page_url&&l(u.ui_settings.sign_in_page_url)};return e.jsx(ge,{children:e.jsxs(nm,{children:[e.jsxs(sm,{children:[e.jsx(am,{children:"Magic Link Verification"}),e.jsx(im,{children:"Verifying your magic link"})]}),e.jsxs(cm,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(um,{}),e.jsx(Ln,{children:s})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(lm,{children:"✓"}),e.jsx(Ln,{children:s})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(dm,{children:"✗"}),e.jsx(Ln,{children:s}),e.jsx(Q,{onClick:v,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function hm(t){var n,s;return t?((n=t.signin_attempts)==null?void 0:n.find(a=>a.requires_completion&&!a.completed))?!0:!!((s=t.signup_attempts)==null?void 0:s.find(a=>{var p,f;return((p=a.missing_fields)==null?void 0:p.length)>0||((f=a.remaining_steps)==null?void 0:f.length)>0&&!a.completed})):!1}function fm(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Nt=d.div`
1948
1948
  max-width: 380px;
1949
1949
  width: 380px;
1950
1950
  padding: var(--space-3xl);
@@ -1990,7 +1990,7 @@ cursor: pointer;
1990
1990
  margin: 0 auto var(--space-lg) auto;
1991
1991
  color: var(--color-error);
1992
1992
  font-size: var(--font-xl);
1993
- `,Di=d.div`
1993
+ `,Da=d.div`
1994
1994
  width: calc(var(--space-3xl) * 2);
1995
1995
  height: calc(var(--space-3xl) * 2);
1996
1996
  border-radius: 50%;
@@ -2026,7 +2026,7 @@ cursor: pointer;
2026
2026
  font-size: var(--font-xs);
2027
2027
  color: var(--color-secondary-text);
2028
2028
  margin-bottom: var(--space-lg);
2029
- `,Ni=d.span`
2029
+ `,Na=d.span`
2030
2030
  color: var(--color-primary);
2031
2031
  font-weight: 400;
2032
2032
  `,xm=d.div`
@@ -2044,7 +2044,7 @@ cursor: pointer;
2044
2044
  &:hover {
2045
2045
  color: var(--color-primary-hover);
2046
2046
  }
2047
- `;function bm({token:t,onSuccess:r,onError:o}){var b;const{acceptInvitation:n,invitationData:s,loading:i,error:u}=$c(),{navigate:f}=Ge(),{deployment:c}=ve(),h=a.useRef(!1),l=()=>{var z;const $=new URLSearchParams(window.location.search);return{token:t||$.get("invite_token")||$.get("token"),redirectUri:$.get("redirect_uri")||((z=c==null?void 0:c.ui_settings)==null?void 0:z.after_signin_redirect_url)||"/"}};a.useEffect(()=>{if(h.current)return;const{token:$}=l();$&&(h.current=!0,n($))},[n]),a.useEffect(()=>{var $;s&&(s.organization&&!s.requires_signin&&r&&r(s.organization.id,($=s.workspace)==null?void 0:$.id),s.error_code&&o&&o(s.message||"Failed to accept invitation"))},[s,r,o]);const p=()=>{const{redirectUri:$}=l();f($)},g=()=>{var v,P;const{token:$}=l(),z=((v=c==null?void 0:c.ui_settings)==null?void 0:v.sign_in_page_url)||"/sign-in",w=((P=c==null?void 0:c.ui_settings)==null?void 0:P.sign_up_page_url)||"/sign-up",y=new URLSearchParams;$&&y.set("invite_token",$),s!=null&&s.invited_email&&y.set("invited_email",s.invited_email);const C=`${window.location.pathname}?token=${$}`;y.set("redirect_uri",C),s!=null&&s.message&&y.set("message",s.message);const _=(s==null?void 0:s.error_code)==="INVITATION_REQUIRES_SIGNUP";f(`${_?w:z}?${y.toString()}`)},x=()=>{const{token:$}=l();$&&(h.current=!1,n($))},{token:m}=l();if(!m&&!i)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invalid Invitation"}),e.jsx(Ut,{children:"No invitation token found"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Missing Invitation Token"}),e.jsx(Gt,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(Q,{onClick:()=>f("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(i)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Processing Invitation"}),e.jsx(Ut,{children:"Please wait while we verify your invitation"})]}),e.jsxs(Wt,{children:[e.jsx(mm,{}),e.jsx(Vt,{children:"Verifying invitation..."}),e.jsx(Gt,{children:"This will only take a moment."})]})]})});if(s!=null&&s.organization&&!s.requires_signin)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Accepted!"}),e.jsx(Ut,{children:"You've successfully joined the organization"})]}),e.jsxs(Wt,{children:[e.jsx(gm,{children:"✓"}),e.jsxs(Vt,{children:["Welcome to ",s.organization.name,"!"]}),s.workspace&&e.jsxs(Gt,{children:["You've been added to the ",s.workspace.name," workspace."]}),e.jsx(Q,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.already_member)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Already a Member"}),e.jsx(Ut,{children:"You're already part of this organization"})]}),e.jsxs(Wt,{children:[e.jsx(Di,{children:"ℹ"}),e.jsxs(Vt,{children:["You're already a member of ",((b=s.organization)==null?void 0:b.name)||"this organization"]}),e.jsx(Gt,{children:"No action needed - you already have access."}),e.jsx(Q,{onClick:p,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.requires_signin){const $=s.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:$?"Sign Up Required":"Sign In Required"}),e.jsx(Ut,{children:"To accept this invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Di,{children:"ℹ"}),e.jsxs(Vt,{children:["This invitation is for ",e.jsx(Ni,{children:s.invited_email})]}),e.jsx(Gt,{children:$?"You need to create an account with this email address to accept the invitation.":s.error_code==="INVITATION_EMAIL_MISMATCH"?"You're currently signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."}),e.jsx(Q,{onClick:g,style:{marginTop:"var(--space-lg)"},children:$?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(s==null?void 0:s.error_code)==="INVITATION_EXPIRED"?e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Expired"}),e.jsx(Ut,{children:"This invitation is no longer valid"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"⏱"}),e.jsxs(Vt,{children:["Invitation for ",e.jsx(Ni,{children:s.invited_email})," has expired"]}),e.jsx(Gt,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):u||s!=null&&s.error_code?e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Error"}),e.jsx(Ut,{children:"Unable to process invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Something went wrong"}),e.jsx(Gt,{children:(s==null?void 0:s.message)||u||"Failed to accept invitation"}),e.jsx(Q,{onClick:x,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(xm,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(vm,{onClick:g,children:"Sign in manually"})]})})]})]})}):null}const Ps=a.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),He=()=>{const t=a.useContext(Ps);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},ym=d.div`
2047
+ `;function bm({token:t,onSuccess:r,onError:o}){var w;const{acceptInvitation:n,invitationData:s,loading:a,error:p}=$c(),{navigate:f}=Ge(),{deployment:c}=ve(),h=i.useRef(!1),l=()=>{var S;const $=new URLSearchParams(window.location.search);return{token:t||$.get("invite_token")||$.get("token"),redirectUri:$.get("redirect_uri")||((S=c==null?void 0:c.ui_settings)==null?void 0:S.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(h.current)return;const{token:$}=l();$&&(h.current=!0,n($))},[n]),i.useEffect(()=>{var $;s&&(s.organization&&!s.requires_signin&&r&&r(s.organization.id,($=s.workspace)==null?void 0:$.id),s.error_code&&o&&o(s.message||"Failed to accept invitation"))},[s,r,o]);const u=()=>{const{redirectUri:$}=l();f($)},g=()=>{var m,b;const{token:$}=l(),S=((m=c==null?void 0:c.ui_settings)==null?void 0:m.sign_in_page_url)||"/sign-in",k=((b=c==null?void 0:c.ui_settings)==null?void 0:b.sign_up_page_url)||"/sign-up",P=new URLSearchParams;$&&P.set("invite_token",$),s!=null&&s.invited_email&&P.set("invited_email",s.invited_email);const z=`${window.location.pathname}?token=${$}`;P.set("redirect_uri",z),s!=null&&s.message&&P.set("message",s.message);const y=(s==null?void 0:s.error_code)==="INVITATION_REQUIRES_SIGNUP";f(`${y?k:S}?${P.toString()}`)},v=()=>{const{token:$}=l();$&&(h.current=!1,n($))},{token:x}=l();if(!x&&!a)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invalid Invitation"}),e.jsx(Ut,{children:"No invitation token found"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Missing Invitation Token"}),e.jsx(Gt,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(Q,{onClick:()=>f("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(a)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Processing Invitation"}),e.jsx(Ut,{children:"Please wait while we verify your invitation"})]}),e.jsxs(Wt,{children:[e.jsx(mm,{}),e.jsx(Vt,{children:"Verifying invitation..."}),e.jsx(Gt,{children:"This will only take a moment."})]})]})});if(s!=null&&s.organization&&!s.requires_signin)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Accepted!"}),e.jsx(Ut,{children:"You've successfully joined the organization"})]}),e.jsxs(Wt,{children:[e.jsx(gm,{children:"✓"}),e.jsxs(Vt,{children:["Welcome to ",s.organization.name,"!"]}),s.workspace&&e.jsxs(Gt,{children:["You've been added to the ",s.workspace.name," workspace."]}),e.jsx(Q,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.already_member)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Already a Member"}),e.jsx(Ut,{children:"You're already part of this organization"})]}),e.jsxs(Wt,{children:[e.jsx(Da,{children:"ℹ"}),e.jsxs(Vt,{children:["You're already a member of ",((w=s.organization)==null?void 0:w.name)||"this organization"]}),e.jsx(Gt,{children:"No action needed - you already have access."}),e.jsx(Q,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.requires_signin){const $=s.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:$?"Sign Up Required":"Sign In Required"}),e.jsx(Ut,{children:"To accept this invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Da,{children:"ℹ"}),e.jsxs(Vt,{children:["This invitation is for ",e.jsx(Na,{children:s.invited_email})]}),e.jsx(Gt,{children:$?"You need to create an account with this email address to accept the invitation.":s.error_code==="INVITATION_EMAIL_MISMATCH"?"You're currently signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."}),e.jsx(Q,{onClick:g,style:{marginTop:"var(--space-lg)"},children:$?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(s==null?void 0:s.error_code)==="INVITATION_EXPIRED"?e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Expired"}),e.jsx(Ut,{children:"This invitation is no longer valid"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"⏱"}),e.jsxs(Vt,{children:["Invitation for ",e.jsx(Na,{children:s.invited_email})," has expired"]}),e.jsx(Gt,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):p||s!=null&&s.error_code?e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Error"}),e.jsx(Ut,{children:"Unable to process invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Something went wrong"}),e.jsx(Gt,{children:(s==null?void 0:s.message)||p||"Failed to accept invitation"}),e.jsx(Q,{onClick:v,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(xm,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(vm,{onClick:g,children:"Sign in manually"})]})})]})]})}):null}const Ps=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),He=()=>{const t=i.useContext(Ps);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},ym=d.div`
2048
2048
  display: flex;
2049
2049
  height: 100%;
2050
2050
  min-height: 400px;
@@ -2119,9 +2119,9 @@ cursor: pointer;
2119
2119
  line-height: 1.4;
2120
2120
  `,Im=d.div`
2121
2121
  flex: 1;
2122
- `,Fi=d.div`
2122
+ `,Fa=d.div`
2123
2123
  margin-bottom: 20px;
2124
- `,Bi=d.label`
2124
+ `,Ba=d.label`
2125
2125
  display: block;
2126
2126
  margin-bottom: 6px;
2127
2127
  font-size: 13px;
@@ -2233,7 +2233,7 @@ cursor: pointer;
2233
2233
  color: white;
2234
2234
  font-size: 12px;
2235
2235
  font-weight: 400;
2236
- `,an=({onSuccess:t,onCancel:r})=>{const[o,n]=a.useState(""),[s,i]=a.useState(""),[u,f]=a.useState(),[c,h]=a.useState(null),[l,p]=a.useState(!1),g=a.useRef(null),{createOrganization:x}=Yo(),{toast:m}=He(),b=_=>{n(_)},$=_=>{if(_.target.files&&_.target.files[0]){const v=_.target.files[0];if(v.size>2*1024*1024){m("File size cannot exceed 2MB","error");return}if(!v.type.startsWith("image/")){m("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),f(v),h(URL.createObjectURL(v))}},z=()=>{var _;(_=g.current)==null||_.click()},w=_=>_.split(" ").map(v=>v[0]).join("").toUpperCase().slice(0,2)||"O";a.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const y=_=>_.trim().replace(/[<>\"'&]/g,""),k=_=>_.length>=2&&_.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(_),C=async()=>{const _=y(o),v=y(s);if(!_){m("Please enter an organization name","error");return}if(!k(_)){m("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(v.length>500){m("Description must be less than 500 characters","error");return}p(!0);try{const P=await x({name:_,description:v,image:u});t==null||t(P)}catch(P){const I=P.message||"Failed to create organization. Please try again.";m(I,"error")}finally{p(!1)}};return e.jsx(ge,{children:e.jsxs(ym,{children:[e.jsxs(wm,{children:[e.jsxs(zl,{hasImage:!!c,onClick:z,children:[c?e.jsx(_m,{src:c,alt:"Organization logo"}):e.jsx(km,{children:w(o||"O")}),e.jsx(Lm,{children:e.jsx(Dm,{children:"Upload Logo"})})]}),e.jsx(Am,{type:"file",ref:g,onChange:$,accept:"image/png, image/jpeg, image/gif",disabled:l}),e.jsx(Cm,{children:"Create new organization"}),e.jsx(Sm,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(jm,{children:[e.jsxs(zm,{children:[e.jsx($m,{children:"Choose your organization name"}),e.jsx(Em,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(Im,{children:[e.jsxs(Fi,{children:[e.jsx(Bi,{children:"Organization name"}),e.jsx(Pm,{type:"text",value:o,onChange:_=>b(_.target.value),placeholder:"Acme Inc.",disabled:l})]}),e.jsxs(Fi,{children:[e.jsx(Bi,{children:"Description (optional)"}),e.jsx(Rm,{value:s,onChange:_=>i(_.target.value),placeholder:"What does your organization do?",disabled:l})]})]}),e.jsxs(Tm,{children:[r?e.jsxs(Mm,{onClick:r,disabled:l,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Om,{onClick:C,disabled:l||!o.trim(),children:l?"Creating...":"Create"})]})]})]})})},Nm=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(ge,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:n,onCancel:r})})})})})})},Fm=d.div`
2236
+ `,an=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[s,a]=i.useState(""),[p,f]=i.useState(),[c,h]=i.useState(null),[l,u]=i.useState(!1),g=i.useRef(null),{createOrganization:v}=Yo(),{toast:x}=He(),w=y=>{n(y)},$=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}c&&URL.revokeObjectURL(c),f(m),h(URL.createObjectURL(m))}},S=()=>{var y;(y=g.current)==null||y.click()},k=y=>y.split(" ").map(m=>m[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const P=y=>y.trim().replace(/[<>\"'&]/g,""),E=y=>y.length>=2&&y.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(y),z=async()=>{const y=P(o),m=P(s);if(!y){x("Please enter an organization name","error");return}if(!E(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}u(!0);try{const b=await v({name:y,description:m,image:p});t==null||t(b)}catch(b){const _=b.message||"Failed to create organization. Please try again.";x(_,"error")}finally{u(!1)}};return e.jsx(ge,{children:e.jsxs(ym,{children:[e.jsxs(wm,{children:[e.jsxs(zl,{hasImage:!!c,onClick:S,children:[c?e.jsx(_m,{src:c,alt:"Organization logo"}):e.jsx(km,{children:k(o||"O")}),e.jsx(Lm,{children:e.jsx(Dm,{children:"Upload Logo"})})]}),e.jsx(Am,{type:"file",ref:g,onChange:$,accept:"image/png, image/jpeg, image/gif",disabled:l}),e.jsx(Cm,{children:"Create new organization"}),e.jsx(Sm,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(jm,{children:[e.jsxs(zm,{children:[e.jsx($m,{children:"Choose your organization name"}),e.jsx(Em,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(Im,{children:[e.jsxs(Fa,{children:[e.jsx(Ba,{children:"Organization name"}),e.jsx(Pm,{type:"text",value:o,onChange:y=>w(y.target.value),placeholder:"Acme Inc.",disabled:l})]}),e.jsxs(Fa,{children:[e.jsx(Ba,{children:"Description (optional)"}),e.jsx(Rm,{value:s,onChange:y=>a(y.target.value),placeholder:"What does your organization do?",disabled:l})]})]}),e.jsxs(Tm,{children:[r?e.jsxs(Mm,{onClick:r,disabled:l,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Om,{onClick:z,disabled:l||!o.trim(),children:l?"Creating...":"Create"})]})]})]})})},Nm=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(ge,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:n,onCancel:r})})})})})})},Fm=d.div`
2237
2237
  position: fixed;
2238
2238
  width: 360px;
2239
2239
  max-width: calc(100vw - 48px);
@@ -2246,27 +2246,27 @@ cursor: pointer;
2246
2246
  @media (max-width: 600px) {
2247
2247
  width: calc(100vw - 48px);
2248
2248
  }
2249
- `,Ui=d.div`
2249
+ `,Ua=d.div`
2250
2250
  display: flex;
2251
2251
  justify-content: space-between;
2252
2252
  align-items: center;
2253
2253
  padding: var(--space-sm) var(--space-md);
2254
2254
  border-bottom: 1px solid var(--color-border);
2255
- `,Wi=d.h3`
2255
+ `,Wa=d.h3`
2256
2256
  margin: 0;
2257
2257
  font-size: var(--font-xs);
2258
2258
  font-weight: 400;
2259
2259
  color: var(--color-foreground);
2260
- `,Vi=d.div`
2260
+ `,Va=d.div`
2261
2261
  padding: var(--space-md);
2262
- `,Gi=d.div`
2262
+ `,Ga=d.div`
2263
2263
  display: flex;
2264
2264
  gap: var(--space-xs);
2265
2265
  justify-content: flex-end;
2266
2266
  padding: var(--space-sm) var(--space-md);
2267
2267
  border-top: 1px solid var(--color-border);
2268
2268
  background: var(--color-background-alt);
2269
- `,Hi=d.button`
2269
+ `,Ha=d.button`
2270
2270
  background: none;
2271
2271
  border: none;
2272
2272
  padding: var(--space-xs);
@@ -2282,7 +2282,7 @@ cursor: pointer;
2282
2282
  color: var(--color-foreground);
2283
2283
  background: var(--color-input-background);
2284
2284
  }
2285
- `,qi=({onClose:t,domain:r,triggerRef:o})=>{const n=a.useRef(null),[s,i]=a.useState(),[u,f]=a.useState(""),[c,h]=a.useState(!1),[l,p]=a.useState(!1),[g,x]=a.useState({top:0,left:0}),{addDomain:m,verifyDomain:b}=Ze(),{toast:$}=He(),z=C=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(C),w=C=>C.trim().toLowerCase().replace(/^https?:\/\//,""),y=async()=>{const C=w(u);if(!C){$("Please enter a domain name","error");return}if(!z(C)){$("Please enter a valid domain name (e.g., example.com)","error");return}if(C.length>253){$("Domain name is too long","error");return}try{const _=await m({fqdn:C});$("Domain added successfully","info"),i(_.data)}catch(_){const v=_.message||"Failed to add domain. Please try again.";$(v,"error")}},k=async()=>{if(!(!s||c)){h(!0);try{await b(s),t==null||t(),$("Domain verified successfully","info")}catch(C){const _=C.message||"Failed to verify domain. Please check DNS records and try again.";$(_,"error")}finally{h(!1)}}};return a.useEffect(()=>{p(!0);const C=setTimeout(()=>{if(!n.current)return;const P=o==null?void 0:o.current,I=360,S=250,T=8;let E=0,j=0;if(!P){const A=n.current.getBoundingClientRect(),B=A.width||I,O=A.height||S;E=Math.max(T,(window.innerHeight-O)/2),j=Math.max(T,(window.innerWidth-B)/2),x({top:E,left:j});return}const R=P.getBoundingClientRect(),M=window.innerHeight-R.bottom,F=R.top;M>=S+T?(E=R.bottom+T,j=R.right-I,j<T&&(j=R.left,j+I>window.innerWidth-T&&(j=(window.innerWidth-I)/2))):F>=S+T?(E=R.top-S-T,j=R.right-I,j<T&&(j=R.left,j+I>window.innerWidth-T&&(j=(window.innerWidth-I)/2))):(E=R.bottom+T,j=R.right-I,j<T&&(j=R.left)),x({top:E,left:j})},10),_=P=>{n.current&&!n.current.contains(P.target)&&(t==null||t())},v=P=>{P.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",v),()=>{clearTimeout(C),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",v)}},[t,o]),a.useEffect(()=>{r&&i(r)},[r]),l?e.jsx(Fm,{ref:n,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:C=>C.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(Ui,{children:[e.jsx(Wi,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Hi,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(et,{size:16})})]}),e.jsxs(Vi,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0,textAlign:"left"},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ae,{children:"Record Type"}),e.jsx(ce,{value:s==null?void 0:s.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Record Name"}),e.jsx(ce,{value:s==null?void 0:s.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Record Data"}),e.jsx(ce,{type:"text",value:s==null?void 0:s.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Gi,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:k,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ui,{children:[e.jsx(Wi,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Hi,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Vi,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ae,{children:"Enter FQDN"}),e.jsx(ce,{type:"text",placeholder:"Enter your domain",value:u,onChange:C=>f(C.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Gi,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:y,disabled:!u||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Bm=d.div`
2285
+ `,qa=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(),[p,f]=i.useState(""),[c,h]=i.useState(!1),[l,u]=i.useState(!1),[g,v]=i.useState({top:0,left:0}),{addDomain:x,verifyDomain:w}=Ze(),{toast:$}=He(),S=z=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(z),k=z=>z.trim().toLowerCase().replace(/^https?:\/\//,""),P=async()=>{const z=k(p);if(!z){$("Please enter a domain name","error");return}if(!S(z)){$("Please enter a valid domain name (e.g., example.com)","error");return}if(z.length>253){$("Domain name is too long","error");return}try{const y=await x({fqdn:z});$("Domain added successfully","info"),a(y.data)}catch(y){const m=y.message||"Failed to add domain. Please try again.";$(m,"error")}},E=async()=>{if(!(!s||c)){h(!0);try{await w(s),t==null||t(),$("Domain verified successfully","info")}catch(z){const y=z.message||"Failed to verify domain. Please check DNS records and try again.";$(y,"error")}finally{h(!1)}}};return i.useEffect(()=>{u(!0);const z=setTimeout(()=>{if(!n.current)return;const b=o==null?void 0:o.current,_=360,j=250,T=8;let R=0,C=0;if(!b){const L=n.current.getBoundingClientRect(),B=L.width||_,O=L.height||j;R=Math.max(T,(window.innerHeight-O)/2),C=Math.max(T,(window.innerWidth-B)/2),v({top:R,left:C});return}const I=b.getBoundingClientRect(),M=window.innerHeight-I.bottom,F=I.top;M>=j+T?(R=I.bottom+T,C=I.right-_,C<T&&(C=I.left,C+_>window.innerWidth-T&&(C=(window.innerWidth-_)/2))):F>=j+T?(R=I.top-j-T,C=I.right-_,C<T&&(C=I.left,C+_>window.innerWidth-T&&(C=(window.innerWidth-_)/2))):(R=I.bottom+T,C=I.right-_,C<T&&(C=I.left)),v({top:R,left:C})},10),y=b=>{n.current&&!n.current.contains(b.target)&&(t==null||t())},m=b=>{b.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",y),document.addEventListener("keydown",m),()=>{clearTimeout(z),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",m)}},[t,o]),i.useEffect(()=>{r&&a(r)},[r]),l?e.jsx(Fm,{ref:n,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(Ua,{children:[e.jsx(Wa,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Ha,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(et,{size:16})})]}),e.jsxs(Va,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0,textAlign:"left"},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Record Type"}),e.jsx(le,{value:s==null?void 0:s.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Record Name"}),e.jsx(le,{value:s==null?void 0:s.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Record Data"}),e.jsx(le,{type:"text",value:s==null?void 0:s.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Ga,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:E,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ua,{children:[e.jsx(Wa,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Ha,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Va,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ce,{children:"Enter FQDN"}),e.jsx(le,{type:"text",placeholder:"Enter your domain",value:p,onChange:z=>f(z.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Ga,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:P,disabled:!p||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Bm=d.div`
2286
2286
  position: fixed;
2287
2287
  width: 360px;
2288
2288
  max-width: calc(100vw - 48px);
@@ -2331,7 +2331,7 @@ cursor: pointer;
2331
2331
  color: var(--color-foreground);
2332
2332
  background: var(--color-input-background);
2333
2333
  }
2334
- `,$l=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const s=a.useRef(null),[i,u]=a.useState(""),[f,c]=a.useState(null),[h,l]=a.useState(!1),[p,g]=a.useState(!1),[x,m]=a.useState({top:0,left:0}),{inviteMember:b}=Ze(),{toast:$}=He(),z=o.map(k=>({value:k.id,label:k.name})),w=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),y=async()=>{const k=i.trim().toLowerCase();if(!(!k||!f)){if(!w(k)){$("Please enter a valid email address","error");return}if(k.length>320){$("Email address is too long","error");return}l(!0);try{await b({email:k,organizationRole:f}),r==null||r()}catch(C){const _=C.message||"Failed to send invitation. Please try again.";$(_,"error")}finally{l(!1)}}};return a.useEffect(()=>{g(!0);const k=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const v=n.current;if(v){const P=v.getBoundingClientRect(),I=360,S=250,T=8;let E=0,j=0;const R=window.innerHeight-P.bottom,M=P.top;R>=S+T?(E=P.bottom+T,j=P.right-I,j<T&&(j=P.left,j+I>window.innerWidth-T&&(j=(window.innerWidth-I)/2))):M>=S+T?(E=P.top-S-T,j=P.right-I,j<T&&(j=P.left,j+I>window.innerWidth-T&&(j=(window.innerWidth-I)/2))):(E=P.bottom+T,j=P.right-I,j<T&&(j=P.left)),m({top:E,left:j})}},10),C=v=>{s.current&&!s.current.contains(v.target)&&(t==null||t())},_=v=>{v.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",C),document.addEventListener("keydown",_),()=>{clearTimeout(k),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",_)}},[t,n]),p?e.jsxs(Bm,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Um,{children:[e.jsx(Wm,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Hm,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Vm,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ae,{children:"Email Address"}),e.jsx(ce,{type:"email",placeholder:"colleague@company.com",value:i,onChange:k=>u(k.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Role"}),e.jsx(Is,{options:z,value:f==null?void 0:f.id,onChange:k=>c(o.find(C=>C.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Gm,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:y,disabled:!i||!f||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},qm=d.div`
2334
+ `,$l=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const s=i.useRef(null),[a,p]=i.useState(""),[f,c]=i.useState(null),[h,l]=i.useState(!1),[u,g]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{inviteMember:w}=Ze(),{toast:$}=He(),S=o.map(E=>({value:E.id,label:E.name})),k=E=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E),P=async()=>{const E=a.trim().toLowerCase();if(!(!E||!f)){if(!k(E)){$("Please enter a valid email address","error");return}if(E.length>320){$("Email address is too long","error");return}l(!0);try{await w({email:E,organizationRole:f}),r==null||r()}catch(z){const y=z.message||"Failed to send invitation. Please try again.";$(y,"error")}finally{l(!1)}}};return i.useEffect(()=>{g(!0);const E=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const m=n.current;if(m){const b=m.getBoundingClientRect(),_=360,j=250,T=8;let R=0,C=0;const I=window.innerHeight-b.bottom,M=b.top;I>=j+T?(R=b.bottom+T,C=b.right-_,C<T&&(C=b.left,C+_>window.innerWidth-T&&(C=(window.innerWidth-_)/2))):M>=j+T?(R=b.top-j-T,C=b.right-_,C<T&&(C=b.left,C+_>window.innerWidth-T&&(C=(window.innerWidth-_)/2))):(R=b.bottom+T,C=b.right-_,C<T&&(C=b.left)),x({top:R,left:C})}},10),z=m=>{s.current&&!s.current.contains(m.target)&&(t==null||t())},y=m=>{m.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",z),document.addEventListener("keydown",y),()=>{clearTimeout(E),document.removeEventListener("mousedown",z),document.removeEventListener("keydown",y)}},[t,n]),u?e.jsxs(Bm,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Um,{children:[e.jsx(Wm,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Hm,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Vm,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Email Address"}),e.jsx(le,{type:"email",placeholder:"colleague@company.com",value:a,onChange:E=>p(E.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Role"}),e.jsx(Is,{options:S,value:f==null?void 0:f.id,onChange:E=>c(o.find(z=>z.id===E)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Gm,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:P,disabled:!a||!f||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},qm=d.div`
2335
2335
  position: fixed;
2336
2336
  width: 400px;
2337
2337
  max-width: calc(100vw - 48px);
@@ -2382,7 +2382,7 @@ cursor: pointer;
2382
2382
  color: var(--color-foreground);
2383
2383
  background: var(--color-input-background);
2384
2384
  }
2385
- `,Yi=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var _;const s=a.useRef(null),[i,u]=a.useState((o==null?void 0:o.name)||""),[f,c]=a.useState((o==null?void 0:o.permissions)||[]);Ze();const[h,l]=a.useState(!1),[p,g]=a.useState(!1),[x,m]=a.useState({top:0,left:0}),{deployment:b}=ve(),{toast:$}=He(),z=!!o,w=Array.isArray((_=b==null?void 0:b.b2b_settings)==null?void 0:_.organization_permissions)?b.b2b_settings.organization_permissions.map(v=>({value:v,label:v})):[];a.useEffect(()=>{g(!0);const v=setTimeout(()=>{if(!s.current)return;let T=null;if(n!=null&&n.current)T=n.current;else if(z){const E=document.querySelectorAll("[data-role-dropdown-trigger]");for(let j=0;j<E.length;j++){const R=E[j];if(R.offsetParent!==null){T=R;break}}}else{const E=document.querySelectorAll("button");for(let j=0;j<E.length;j++){const R=E[j];if(R.textContent==="Add role"&&R.offsetParent!==null){T=R;break}}}if(T){const E=T.getBoundingClientRect(),j=400;let R=E.bottom+8,M=E.right-j;M<10&&(M=E.left),R+300>window.innerHeight&&(R=E.top-300-8),m({top:R,left:M})}},10),P=T=>{s.current&&!s.current.contains(T.target)&&(t==null||t())},I=T=>{T.key==="Escape"&&(t==null||t())},S=setTimeout(()=>{document.addEventListener("mousedown",P),document.addEventListener("keydown",I)},100);return()=>{clearTimeout(v),clearTimeout(S),document.removeEventListener("mousedown",P),document.removeEventListener("keydown",I)}},[t,z,n]);const y=v=>v.trim().replace(/[<>\"'&]/g,""),k=v=>v.length>=2&&v.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(v),C=async()=>{const v=y(i);if(!v){$("Please enter a role name","error");return}if(!k(v)){$("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(f.length===0){$("Please select at least one permission","error");return}l(!0);try{const P={id:o==null?void 0:o.id,name:v,permissions:f||[]};r==null||r(P)}catch(P){const I=P.message||`Failed to ${z?"update":"create"} role. Please try again.`;$(I,"error")}finally{l(!1)}};return p?e.jsxs(qm,{ref:s,$isInTable:z,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(Ym,{children:[e.jsx(Zm,{id:"role-dialog-title",children:z?"Edit Role":"Create New Role"}),e.jsx(Xm,{onClick:t,"aria-label":`Close ${z?"edit":"create"} role dialog`,children:e.jsx(et,{size:16})})]}),e.jsx(Km,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ae,{children:"Role Name"}),e.jsx(ce,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:i,onChange:v=>u(v.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Permissions"}),e.jsx(bl,{options:w,value:f,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Qm,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:C,disabled:!i||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," ",z?"Updating...":"Creating..."]}):z?"Update Role":"Create Role"})]})]}):null},ht=d.table`
2385
+ `,Ya=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var y;const s=i.useRef(null),[a,p]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]);Ze();const[h,l]=i.useState(!1),[u,g]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{deployment:w}=ve(),{toast:$}=He(),S=!!o,k=Array.isArray((y=w==null?void 0:w.b2b_settings)==null?void 0:y.organization_permissions)?w.b2b_settings.organization_permissions.map(m=>({value:m,label:m})):[];i.useEffect(()=>{g(!0);const m=setTimeout(()=>{if(!s.current)return;let T=null;if(n!=null&&n.current)T=n.current;else if(S){const R=document.querySelectorAll("[data-role-dropdown-trigger]");for(let C=0;C<R.length;C++){const I=R[C];if(I.offsetParent!==null){T=I;break}}}else{const R=document.querySelectorAll("button");for(let C=0;C<R.length;C++){const I=R[C];if(I.textContent==="Add role"&&I.offsetParent!==null){T=I;break}}}if(T){const R=T.getBoundingClientRect(),C=400;let I=R.bottom+8,M=R.right-C;M<10&&(M=R.left),I+300>window.innerHeight&&(I=R.top-300-8),x({top:I,left:M})}},10),b=T=>{s.current&&!s.current.contains(T.target)&&(t==null||t())},_=T=>{T.key==="Escape"&&(t==null||t())},j=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",_)},100);return()=>{clearTimeout(m),clearTimeout(j),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",_)}},[t,S,n]);const P=m=>m.trim().replace(/[<>\"'&]/g,""),E=m=>m.length>=2&&m.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(m),z=async()=>{const m=P(a);if(!m){$("Please enter a role name","error");return}if(!E(m)){$("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(f.length===0){$("Please select at least one permission","error");return}l(!0);try{const b={id:o==null?void 0:o.id,name:m,permissions:f||[]};r==null||r(b)}catch(b){const _=b.message||`Failed to ${S?"update":"create"} role. Please try again.`;$(_,"error")}finally{l(!1)}};return u?e.jsxs(qm,{ref:s,$isInTable:S,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:m=>m.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(Ym,{children:[e.jsx(Zm,{id:"role-dialog-title",children:S?"Edit Role":"Create New Role"}),e.jsx(Xm,{onClick:t,"aria-label":`Close ${S?"edit":"create"} role dialog`,children:e.jsx(et,{size:16})})]}),e.jsx(Km,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Role Name"}),e.jsx(le,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:m=>p(m.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Permissions"}),e.jsx(bl,{options:k,value:f,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Qm,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:z,disabled:!a||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," ",S?"Updating...":"Creating..."]}):S?"Update Role":"Create Role"})]})]}):null},ht=d.table`
2386
2386
  width: 100%;
2387
2387
  border-collapse: separate;
2388
2388
  border-spacing: 0;
@@ -2463,7 +2463,7 @@ cursor: pointer;
2463
2463
  margin: 0;
2464
2464
  max-width: 380px;
2465
2465
  line-height: 1.5;
2466
- `,at=({title:t,description:r,action:o})=>e.jsxs(Jm,{children:[e.jsx(ex,{children:t}),e.jsx(tx,{children:r}),o&&e.jsx("div",{style:{marginTop:"24px"},children:o})]}),rx=d.div`
2466
+ `,it=({title:t,description:r,action:o})=>e.jsxs(Jm,{children:[e.jsx(ex,{children:t}),e.jsx(tx,{children:r}),o&&e.jsx("div",{style:{marginTop:"24px"},children:o})]}),rx=d.div`
2467
2467
  text-align: left;
2468
2468
  position: fixed;
2469
2469
  background: var(--color-background);
@@ -2483,7 +2483,7 @@ cursor: pointer;
2483
2483
  display: flex;
2484
2484
  gap: 8px;
2485
2485
  justify-content: flex-end;
2486
- `,Yr=({title:t,onConfirm:r,onCancel:o})=>{const n=a.useRef(null),[s,i]=a.useState({top:0,left:0});return a.useEffect(()=>{var u;if(n.current){const f=(u=n.current.parentElement)==null?void 0:u.getBoundingClientRect();f&&i({top:f.bottom+8,left:f.right-320})}},[]),a.useEffect(()=>{const u=f=>{n.current&&!n.current.contains(f.target)&&o()};return document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[o]),e.jsxs(rx,{ref:n,style:{top:`${s.top}px`,left:`${s.left}px`},children:[e.jsx(ox,{children:t}),e.jsxs(nx,{children:[e.jsx(Q,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(Q,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},sx=d.div`
2486
+ `,Yr=({title:t,onConfirm:r,onCancel:o})=>{const n=i.useRef(null),[s,a]=i.useState({top:0,left:0});return i.useEffect(()=>{var p;if(n.current){const f=(p=n.current.parentElement)==null?void 0:p.getBoundingClientRect();f&&a({top:f.bottom+8,left:f.right-320})}},[]),i.useEffect(()=>{const p=f=>{n.current&&!n.current.contains(f.target)&&o()};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[o]),e.jsxs(rx,{ref:n,style:{top:`${s.top}px`,left:`${s.left}px`},children:[e.jsx(ox,{children:t}),e.jsxs(nx,{children:[e.jsx(Q,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(Q,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},sx=d.div`
2487
2487
  display: flex;
2488
2488
  align-items: center;
2489
2489
  flex-wrap: wrap;
@@ -2495,7 +2495,7 @@ cursor: pointer;
2495
2495
  border-radius: 8px;
2496
2496
  padding: 20px;
2497
2497
  margin-bottom: 16px;
2498
- `,ix=d.div`
2498
+ `,ax=d.div`
2499
2499
  display: flex;
2500
2500
  justify-content: space-between;
2501
2501
  align-items: flex-start;
@@ -2508,7 +2508,7 @@ cursor: pointer;
2508
2508
  display: flex;
2509
2509
  align-items: center;
2510
2510
  gap: 8px;
2511
- `,ax=d.span`
2511
+ `,ix=d.span`
2512
2512
  background: var(--color-primary-background);
2513
2513
  color: var(--color-primary);
2514
2514
  padding: 4px 8px;
@@ -2538,7 +2538,7 @@ cursor: pointer;
2538
2538
  background: var(--color-input-background);
2539
2539
  color: var(--color-foreground);
2540
2540
  }
2541
- `,Zi=d.div`
2541
+ `,Za=d.div`
2542
2542
  padding: 12px 16px;
2543
2543
  background: var(--color-background-alt);
2544
2544
  border-radius: 8px;
@@ -2563,12 +2563,12 @@ cursor: pointer;
2563
2563
  outline: none;
2564
2564
  border-color: var(--color-primary);
2565
2565
  }
2566
- `,Ki=[{id:"okta",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"saml",description:"SAML",docUrl:"https://help.okta.com/en-us/content/topics/apps/apps_app_integration_wizard_saml.htm",placeholders:{entityId:"http://www.okta.com/{yourOktaDomain}",ssoUrl:"https://{yourOktaDomain}.okta.com/app/{appId}/sso/saml"},attributeMapping:{first_name:"firstName",last_name:"lastName",email:"email"}},{id:"okta-oidc",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"oidc",description:"OIDC",docUrl:"https://developer.okta.com/docs/guides/implement-oauth-for-okta/main/",placeholders:{issuerUrl:"https://{yourOktaDomain}.okta.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"azure",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-sso",placeholders:{entityId:"https://sts.windows.net/{tenantId}/",ssoUrl:"https://login.microsoftonline.com/{tenantId}/saml2"},attributeMapping:{first_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",last_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",email:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"}},{id:"azure-oidc",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"oidc",description:"OIDC",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc",placeholders:{issuerUrl:"https://login.microsoftonline.com/{tenantId}/v2.0",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"google",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"saml",description:"SAML",docUrl:"https://support.google.com/a/answer/6087519",placeholders:{entityId:"https://accounts.google.com/o/saml2?idpid={idpId}",ssoUrl:"https://accounts.google.com/o/saml2/idp?idpid={idpId}"},attributeMapping:{first_name:"FirstName",last_name:"LastName",email:"email"}},{id:"google-oidc",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"oidc",description:"OIDC",docUrl:"https://developers.google.com/identity/openid-connect/openid-connect",placeholders:{issuerUrl:"https://accounts.google.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"auth0",name:"Auth0",logo:"https://cdn.auth0.com/styleguide/latest/lib/logos/img/badge.png",protocol:"oidc",description:"OIDC",docUrl:"https://auth0.com/docs/authenticate/protocols/openid-connect-protocol",placeholders:{issuerUrl:"https://{yourDomain}.auth0.com/",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"onelogin",name:"OneLogin",logo:"",protocol:"saml",description:"SAML",docUrl:"https://onelogin.service-now.com/support?id=kb_article&sys_id=912bb23adbdc1cd0ca1c400e0b96197d",placeholders:{entityId:"https://app.onelogin.com/saml/metadata/{appId}",ssoUrl:"https://{subdomain}.onelogin.com/trust/saml2/http-post/sso/{appId}"}},{id:"ping",name:"PingOne",logo:"",protocol:"saml",description:"SAML",docUrl:"https://docs.pingidentity.com/pingone/latest/connector/configure-saml.html",placeholders:{entityId:"https://auth.pingone.com/{envId}",ssoUrl:"https://auth.pingone.com/{envId}/saml20/idp/sso"}},{id:"jumpcloud",name:"JumpCloud",logo:"",protocol:"saml",description:"SAML",docUrl:"https://support.jumpcloud.com/support/s/article/single-sign-on-sso-with-saml",placeholders:{entityId:"https://sso.jumpcloud.com/saml2/{appId}",ssoUrl:"https://sso.jumpcloud.com/saml2/{appId}"}},{id:"duo",name:"Duo",logo:"",protocol:"saml",description:"SAML",docUrl:"https://duo.com/docs/sso",placeholders:{entityId:"https://sso.duosecurity.com/saml2/sp/{appId}",ssoUrl:"https://sso.duosecurity.com/saml2/idp/{appId}/sso"}},{id:"keycloak",name:"Keycloak",logo:"https://www.keycloak.org/resources/images/icon.svg",protocol:"oidc",description:"OIDC",docUrl:"https://www.keycloak.org/docs/latest/securing_apps/",placeholders:{issuerUrl:"https://{host}/realms/{realm}",scopes:"openid profile email"}},{id:"adfs",name:"ADFS",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Microsoft_logo.svg/100px-Microsoft_logo.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/operations/create-a-relying-party-trust",placeholders:{entityId:"http://{adfsServer}/adfs/services/trust",ssoUrl:"https://{adfsServer}/adfs/ls/"}},{id:"custom-saml",name:"Custom",logo:"",protocol:"saml",description:"SAML",docUrl:"",placeholders:{}},{id:"custom-oidc",name:"Custom",logo:"",protocol:"oidc",description:"OIDC",docUrl:"",placeholders:{}}],Qi=d.div`
2566
+ `,Ka=[{id:"okta",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"saml",description:"SAML",docUrl:"https://help.okta.com/en-us/content/topics/apps/apps_app_integration_wizard_saml.htm",placeholders:{entityId:"http://www.okta.com/{yourOktaDomain}",ssoUrl:"https://{yourOktaDomain}.okta.com/app/{appId}/sso/saml"},attributeMapping:{first_name:"firstName",last_name:"lastName",email:"email"}},{id:"okta-oidc",name:"Okta",logo:"https://www.okta.com/sites/default/files/Okta_Logo_BrightBlue_Medium.png",protocol:"oidc",description:"OIDC",docUrl:"https://developer.okta.com/docs/guides/implement-oauth-for-okta/main/",placeholders:{issuerUrl:"https://{yourOktaDomain}.okta.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"azure",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/add-application-portal-setup-sso",placeholders:{entityId:"https://sts.windows.net/{tenantId}/",ssoUrl:"https://login.microsoftonline.com/{tenantId}/saml2"},attributeMapping:{first_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname",last_name:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname",email:"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"}},{id:"azure-oidc",name:"Azure AD",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Microsoft_Azure.svg/150px-Microsoft_Azure.svg.png",protocol:"oidc",description:"OIDC",docUrl:"https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc",placeholders:{issuerUrl:"https://login.microsoftonline.com/{tenantId}/v2.0",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"google",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"saml",description:"SAML",docUrl:"https://support.google.com/a/answer/6087519",placeholders:{entityId:"https://accounts.google.com/o/saml2?idpid={idpId}",ssoUrl:"https://accounts.google.com/o/saml2/idp?idpid={idpId}"},attributeMapping:{first_name:"FirstName",last_name:"LastName",email:"email"}},{id:"google-oidc",name:"Google",logo:"https://www.gstatic.com/images/branding/product/1x/googleg_48dp.png",protocol:"oidc",description:"OIDC",docUrl:"https://developers.google.com/identity/openid-connect/openid-connect",placeholders:{issuerUrl:"https://accounts.google.com",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"auth0",name:"Auth0",logo:"https://cdn.auth0.com/styleguide/latest/lib/logos/img/badge.png",protocol:"oidc",description:"OIDC",docUrl:"https://auth0.com/docs/authenticate/protocols/openid-connect-protocol",placeholders:{issuerUrl:"https://{yourDomain}.auth0.com/",scopes:"openid profile email"},attributeMapping:{first_name:"given_name",last_name:"family_name",email:"email"}},{id:"onelogin",name:"OneLogin",logo:"",protocol:"saml",description:"SAML",docUrl:"https://onelogin.service-now.com/support?id=kb_article&sys_id=912bb23adbdc1cd0ca1c400e0b96197d",placeholders:{entityId:"https://app.onelogin.com/saml/metadata/{appId}",ssoUrl:"https://{subdomain}.onelogin.com/trust/saml2/http-post/sso/{appId}"}},{id:"ping",name:"PingOne",logo:"",protocol:"saml",description:"SAML",docUrl:"https://docs.pingidentity.com/pingone/latest/connector/configure-saml.html",placeholders:{entityId:"https://auth.pingone.com/{envId}",ssoUrl:"https://auth.pingone.com/{envId}/saml20/idp/sso"}},{id:"jumpcloud",name:"JumpCloud",logo:"",protocol:"saml",description:"SAML",docUrl:"https://support.jumpcloud.com/support/s/article/single-sign-on-sso-with-saml",placeholders:{entityId:"https://sso.jumpcloud.com/saml2/{appId}",ssoUrl:"https://sso.jumpcloud.com/saml2/{appId}"}},{id:"duo",name:"Duo",logo:"",protocol:"saml",description:"SAML",docUrl:"https://duo.com/docs/sso",placeholders:{entityId:"https://sso.duosecurity.com/saml2/sp/{appId}",ssoUrl:"https://sso.duosecurity.com/saml2/idp/{appId}/sso"}},{id:"keycloak",name:"Keycloak",logo:"https://www.keycloak.org/resources/images/icon.svg",protocol:"oidc",description:"OIDC",docUrl:"https://www.keycloak.org/docs/latest/securing_apps/",placeholders:{issuerUrl:"https://{host}/realms/{realm}",scopes:"openid profile email"}},{id:"adfs",name:"ADFS",logo:"https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Microsoft_logo.svg/100px-Microsoft_logo.svg.png",protocol:"saml",description:"SAML",docUrl:"https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/operations/create-a-relying-party-trust",placeholders:{entityId:"http://{adfsServer}/adfs/services/trust",ssoUrl:"https://{adfsServer}/adfs/ls/"}},{id:"custom-saml",name:"Custom",logo:"",protocol:"saml",description:"SAML",docUrl:"",placeholders:{}},{id:"custom-oidc",name:"Custom",logo:"",protocol:"oidc",description:"OIDC",docUrl:"",placeholders:{}}],Qa=d.div`
2567
2567
  display: grid;
2568
2568
  grid-template-columns: repeat(4, 1fr);
2569
2569
  gap: 8px;
2570
2570
  margin-bottom: 16px;
2571
- `,Xi=d.button`
2571
+ `,Xa=d.button`
2572
2572
  display: flex;
2573
2573
  flex-direction: column;
2574
2574
  align-items: center;
@@ -2592,12 +2592,12 @@ cursor: pointer;
2592
2592
  background: white;
2593
2593
  border-radius: 4px;
2594
2594
  padding: 3px;
2595
- `,Ji=d.span`
2595
+ `,Ja=d.span`
2596
2596
  font-size: 11px;
2597
2597
  font-weight: 500;
2598
2598
  color: var(--color-foreground);
2599
2599
  text-align: center;
2600
- `,ea=d.select`
2600
+ `,ei=d.select`
2601
2601
  width: 100%;
2602
2602
  padding: 10px 12px;
2603
2603
  border: 1px solid var(--color-border);
@@ -2611,7 +2611,7 @@ cursor: pointer;
2611
2611
  outline: none;
2612
2612
  border-color: var(--color-primary);
2613
2613
  }
2614
- `,lx=()=>{var y;const{deployment:t}=ve(),{activeOrganization:r,loading:o,getEnterpriseConnections:n,createEnterpriseConnection:s,deleteEnterpriseConnection:i,testEnterpriseConnection:u,generateSCIMToken:f,getSCIMToken:c,revokeSCIMToken:h}=Ze(),{toast:l}=He(),[p,g]=a.useState(!1),[x,m]=a.useState(null),{data:b=[],isLoading:$,mutate:z}=Be(r!=null&&r.id?`wacht-org-sso:${r.id}`:null,async()=>await(n==null?void 0:n())||[],{refreshInterval:3e4,revalidateOnFocus:!1}),w=async k=>{try{await(i==null?void 0:i(k)),z(),l("SSO connection deleted","info")}catch(C){l(C.message||"Failed to delete connection","error")}m(null)};return o||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):(y=t==null?void 0:t.b2b_settings)!=null&&y.enterprise_sso_enabled?p?e.jsx(gx,{onClose:()=>g(!1),onCreate:async k=>{try{await(s==null?void 0:s(k)),z(),g(!1),l("SSO connection created","info")}catch(C){l(C.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:b.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(Qe,{size:56,strokeWidth:1,style:{color:"var(--color-primary)",marginBottom:"20px",opacity:.7}}),e.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:500,color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:"var(--color-muted)",maxWidth:"360px",lineHeight:"1.6"},children:"Set up SAML or OIDC single sign-on to allow members to sign in with your identity provider."}),e.jsxs(Q,{onClick:()=>g(!0),style:{width:"auto"},children:[e.jsx(Ke,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(sx,{children:e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"16px",color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"var(--color-muted)"},children:"Configure SAML or OIDC SSO for your organization"})]})}),b.map(k=>e.jsx(fx,{connection:k,onDelete:C=>m(C),connectionToDelete:x,onConfirmDelete:w,onCancelDelete:()=>m(null),testConnection:u||null,generateSCIMToken:f,getSCIMToken:c,revokeSCIMToken:h,toast:l},k.id))]})}):e.jsxs(Il,{children:[e.jsxs(Pl,{children:[e.jsx(Qe,{size:18}),"Enterprise SSO"]}),e.jsx(Ht,{children:e.jsx("span",{style:{color:"var(--color-foreground-muted)"},children:"Enterprise SSO is not enabled for this deployment. Contact your administrator to enable this feature."})})]})},dx=d.div`
2614
+ `,lx=()=>{var P;const{deployment:t}=ve(),{activeOrganization:r,loading:o,getEnterpriseConnections:n,createEnterpriseConnection:s,deleteEnterpriseConnection:a,testEnterpriseConnection:p,generateSCIMToken:f,getSCIMToken:c,revokeSCIMToken:h}=Ze(),{toast:l}=He(),[u,g]=i.useState(!1),[v,x]=i.useState(null),{data:w=[],isLoading:$,mutate:S}=Fe(r!=null&&r.id?`wacht-org-sso:${r.id}`:null,async()=>await(n==null?void 0:n())||[],{refreshInterval:3e4,revalidateOnFocus:!1}),k=async E=>{try{await(a==null?void 0:a(E)),S(),l("SSO connection deleted","info")}catch(z){l(z.message||"Failed to delete connection","error")}x(null)};return o||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):(P=t==null?void 0:t.b2b_settings)!=null&&P.enterprise_sso_enabled?u?e.jsx(gx,{onClose:()=>g(!1),onCreate:async E=>{try{await(s==null?void 0:s(E)),S(),g(!1),l("SSO connection created","info")}catch(z){l(z.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:w.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(Qe,{size:56,strokeWidth:1,style:{color:"var(--color-primary)",marginBottom:"20px",opacity:.7}}),e.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:500,color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:"var(--color-muted)",maxWidth:"360px",lineHeight:"1.6"},children:"Set up SAML or OIDC single sign-on to allow members to sign in with your identity provider."}),e.jsxs(Q,{onClick:()=>g(!0),style:{width:"auto"},children:[e.jsx(Ke,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(sx,{children:e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"16px",color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"var(--color-muted)"},children:"Configure SAML or OIDC SSO for your organization"})]})}),w.map(E=>e.jsx(fx,{connection:E,onDelete:z=>x(z),connectionToDelete:v,onConfirmDelete:k,onCancelDelete:()=>x(null),testConnection:p||null,generateSCIMToken:f,getSCIMToken:c,revokeSCIMToken:h,toast:l},E.id))]})}):e.jsxs(Il,{children:[e.jsxs(Pl,{children:[e.jsx(Qe,{size:18}),"Enterprise SSO"]}),e.jsx(Ht,{children:e.jsx("span",{style:{color:"var(--color-foreground-muted)"},children:"Enterprise SSO is not enabled for this deployment. Contact your administrator to enable this feature."})})]})},dx=d.div`
2615
2615
  margin-top: 16px;
2616
2616
  padding-top: 16px;
2617
2617
  border-top: 1px solid var(--color-border);
@@ -2636,14 +2636,14 @@ cursor: pointer;
2636
2636
  display: flex;
2637
2637
  gap: 8px;
2638
2638
  flex-wrap: wrap;
2639
- `,fx=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:s,testConnection:i,generateSCIMToken:u,getSCIMToken:f,revokeSCIMToken:c,toast:h})=>{var S,T;const[l,p]=a.useState(null),[g,x]=a.useState(!1),[m,b]=a.useState(null),[$,z]=a.useState(null),[w,y]=a.useState(!1),[k,C]=a.useState(null);a.useEffect(()=>{f&&t.id&&f(t.id).then(p).catch(()=>{})},[t.id,f]);const _=async()=>{if(i){y(!0),C(null);try{const E=await i(t.id);C(E)}catch(E){C({success:!1,checks:{},errors:{general:E.message||"Test failed"}})}finally{y(!1)}}},v=async()=>{if(u){x(!0);try{const E=await u(t.id);b(E.token),p({exists:!0,token:E,scim_base_url:E.scim_base_url}),h("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(E){h(E.message||"Failed to generate token","error")}finally{x(!1)}}},P=async()=>{if(c){x(!0);try{await c(t.id),p({exists:!1,scim_base_url:l==null?void 0:l.scim_base_url}),b(null),h("SCIM token revoked","info")}catch(E){h(E.message||"Failed to revoke token","error")}finally{x(!1)}}},I=(E,j)=>{navigator.clipboard.writeText(E),z(j),setTimeout(()=>z(null),2e3)};return e.jsxs(Il,{children:[e.jsxs(ix,{children:[e.jsxs(Pl,{children:[e.jsx(Qe,{size:18}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(ax,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(br,{onClick:()=>r(t.id),style:{color:"var(--color-error)"},children:e.jsx(Hr,{size:16})}),o===t.id&&e.jsx(Yr,{title:"Delete this SSO connection?",onConfirm:()=>n(t.id),onCancel:s})]})]}),t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(Ht,{children:[e.jsx("strong",{children:"Entity ID:"})," ",t.idp_entity_id]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"SSO URL:"})," ",t.idp_sso_url]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ht,{children:[e.jsx("strong",{children:"Issuer URL:"})," ",t.oidc_issuer_url]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Client ID:"})," ",t.oidc_client_id]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Scopes:"})," ",t.oidc_scopes||"openid profile email"]})]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Created:"})," ",new Date(t.created_at).toLocaleDateString()]}),e.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[e.jsxs(Q,{$outline:!0,onClick:_,disabled:w,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[w?e.jsx(Ee,{size:12}):e.jsx(Qe,{size:14}),w?"Testing...":"Test Connection"]}),k&&e.jsx("span",{style:{fontSize:"12px",color:k.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:k.success?"✓ Connection valid":"✗ Connection failed"})]}),k&&!k.success&&k.errors&&e.jsx("div",{style:{marginTop:"8px",padding:"8px 12px",background:"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"4px",fontSize:"12px"},children:Object.entries(k.errors).map(([E,j])=>e.jsxs("div",{style:{color:"var(--color-error)",marginBottom:"4px"},children:[e.jsxs("strong",{children:[E.replace(/_/g," ").replace(/\b\w/g,R=>R.toUpperCase()),":"]})," ",j]},E))})]}),e.jsxs(dx,{children:[e.jsxs(ux,{children:[e.jsx(Qe,{size:14}),"SCIM Provisioning"]}),(l==null?void 0:l.scim_base_url)&&e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"4px"},children:"SCIM Base URL:"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all"},children:l.scim_base_url}),e.jsx(br,{onClick:()=>I(l.scim_base_url,"scim-url"),children:$==="scim-url"?e.jsx(Ve,{size:14}):e.jsx(Jt,{size:14})})]})]}),m&&e.jsxs(px,{children:[e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginBottom:"8px"},children:"⚠️ Copy this token now. It won't be shown again."}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[e.jsx("span",{style:{flex:1},children:m}),e.jsx(br,{onClick:()=>I(m,"scim-token"),children:$==="scim-token"?e.jsx(Ve,{size:14}):e.jsx(Jt,{size:14})})]})]}),(l==null?void 0:l.exists)&&((S=l==null?void 0:l.token)==null?void 0:S.enabled)&&!m&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:["Token: ",e.jsxs("code",{children:[l.token.token_prefix,"..."]}),l.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(l.token.last_used_at).toLocaleDateString()]})]}),e.jsx(hx,{children:!(l!=null&&l.exists)||!((T=l==null?void 0:l.token)!=null&&T.enabled)?e.jsxs(Q,{onClick:v,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[g?e.jsx(Ee,{size:12}):e.jsx(Ke,{size:14}),"Generate SCIM Token"]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{$outline:!0,onClick:v,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:"Rotate Token"}),e.jsx(Q,{$outline:!0,onClick:P,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px",color:"var(--color-error)"},children:"Revoke Token"})]})})]})]})},Fn=d.h3`
2639
+ `,fx=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:s,testConnection:a,generateSCIMToken:p,getSCIMToken:f,revokeSCIMToken:c,toast:h})=>{var j,T;const[l,u]=i.useState(null),[g,v]=i.useState(!1),[x,w]=i.useState(null),[$,S]=i.useState(null),[k,P]=i.useState(!1),[E,z]=i.useState(null);i.useEffect(()=>{f&&t.id&&f(t.id).then(u).catch(()=>{})},[t.id,f]);const y=async()=>{if(a){P(!0),z(null);try{const R=await a(t.id);z(R)}catch(R){z({success:!1,checks:{},errors:{general:R.message||"Test failed"}})}finally{P(!1)}}},m=async()=>{if(p){v(!0);try{const R=await p(t.id);w(R.token),u({exists:!0,token:R,scim_base_url:R.scim_base_url}),h("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(R){h(R.message||"Failed to generate token","error")}finally{v(!1)}}},b=async()=>{if(c){v(!0);try{await c(t.id),u({exists:!1,scim_base_url:l==null?void 0:l.scim_base_url}),w(null),h("SCIM token revoked","info")}catch(R){h(R.message||"Failed to revoke token","error")}finally{v(!1)}}},_=(R,C)=>{navigator.clipboard.writeText(R),S(C),setTimeout(()=>S(null),2e3)};return e.jsxs(Il,{children:[e.jsxs(ax,{children:[e.jsxs(Pl,{children:[e.jsx(Qe,{size:18}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(ix,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(br,{onClick:()=>r(t.id),style:{color:"var(--color-error)"},children:e.jsx(Hr,{size:16})}),o===t.id&&e.jsx(Yr,{title:"Delete this SSO connection?",onConfirm:()=>n(t.id),onCancel:s})]})]}),t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(Ht,{children:[e.jsx("strong",{children:"Entity ID:"})," ",t.idp_entity_id]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"SSO URL:"})," ",t.idp_sso_url]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ht,{children:[e.jsx("strong",{children:"Issuer URL:"})," ",t.oidc_issuer_url]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Client ID:"})," ",t.oidc_client_id]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Scopes:"})," ",t.oidc_scopes||"openid profile email"]})]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Created:"})," ",new Date(t.created_at).toLocaleDateString()]}),e.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[e.jsxs(Q,{$outline:!0,onClick:y,disabled:k,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[k?e.jsx(Ee,{size:12}):e.jsx(Qe,{size:14}),k?"Testing...":"Test Connection"]}),E&&e.jsx("span",{style:{fontSize:"12px",color:E.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:E.success?"✓ Connection valid":"✗ Connection failed"})]}),E&&!E.success&&E.errors&&e.jsx("div",{style:{marginTop:"8px",padding:"8px 12px",background:"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"4px",fontSize:"12px"},children:Object.entries(E.errors).map(([R,C])=>e.jsxs("div",{style:{color:"var(--color-error)",marginBottom:"4px"},children:[e.jsxs("strong",{children:[R.replace(/_/g," ").replace(/\b\w/g,I=>I.toUpperCase()),":"]})," ",C]},R))})]}),e.jsxs(dx,{children:[e.jsxs(ux,{children:[e.jsx(Qe,{size:14}),"SCIM Provisioning"]}),(l==null?void 0:l.scim_base_url)&&e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"4px"},children:"SCIM Base URL:"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all"},children:l.scim_base_url}),e.jsx(br,{onClick:()=>_(l.scim_base_url,"scim-url"),children:$==="scim-url"?e.jsx(Ve,{size:14}):e.jsx(Jt,{size:14})})]})]}),x&&e.jsxs(px,{children:[e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginBottom:"8px"},children:"⚠️ Copy this token now. It won't be shown again."}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[e.jsx("span",{style:{flex:1},children:x}),e.jsx(br,{onClick:()=>_(x,"scim-token"),children:$==="scim-token"?e.jsx(Ve,{size:14}):e.jsx(Jt,{size:14})})]})]}),(l==null?void 0:l.exists)&&((j=l==null?void 0:l.token)==null?void 0:j.enabled)&&!x&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:["Token: ",e.jsxs("code",{children:[l.token.token_prefix,"..."]}),l.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(l.token.last_used_at).toLocaleDateString()]})]}),e.jsx(hx,{children:!(l!=null&&l.exists)||!((T=l==null?void 0:l.token)!=null&&T.enabled)?e.jsxs(Q,{onClick:m,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[g?e.jsx(Ee,{size:12}):e.jsx(Ke,{size:14}),"Generate SCIM Token"]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{$outline:!0,onClick:m,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:"Rotate Token"}),e.jsx(Q,{$outline:!0,onClick:b,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px",color:"var(--color-error)"},children:"Revoke Token"})]})})]})]})},Fn=d.h3`
2640
2640
  margin: 0 0 12px 0;
2641
2641
  font-size: 13px;
2642
2642
  font-weight: 600;
2643
2643
  color: var(--color-foreground);
2644
2644
  text-transform: uppercase;
2645
2645
  letter-spacing: 0.5px;
2646
- `,gx=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=Ze(),{deployment:n}=ve(),[s,i]=a.useState(!1),[u,f]=a.useState(null),[c,h]=a.useState("saml"),[l,p]=a.useState(null),[g,x]=a.useState(!1),[m,b]=a.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:""}),[$,z]=a.useState(!1),[w,y]=a.useState(null),{data:k=[],isLoading:C}=Be("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(R=>R.verified),{revalidateOnFocus:!1}),_=j=>{f(j),h(j.protocol),j.protocol==="saml"?b(R=>{var M,F,A;return{...R,idp_entity_id:j.placeholders.entityId||"",idp_sso_url:j.placeholders.ssoUrl||"",attr_first_name:((M=j.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((F=j.attributeMapping)==null?void 0:F.last_name)||"",attr_email:((A=j.attributeMapping)==null?void 0:A.email)||""}}):b(R=>{var M,F,A;return{...R,oidc_issuer_url:j.placeholders.issuerUrl||"",oidc_scopes:j.placeholders.scopes||"openid profile email",attr_first_name:((M=j.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((F=j.attributeMapping)==null?void 0:F.last_name)||"",attr_email:((A=j.attributeMapping)==null?void 0:A.email)||""}})},v=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",P=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",I=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",S=(j,R)=>{navigator.clipboard.writeText(j),p(R),setTimeout(()=>p(null),2e3)},T=async j=>{j.preventDefault(),i(!0);try{const R={};m.attr_first_name&&(R.first_name=m.attr_first_name),m.attr_last_name&&(R.last_name=m.attr_last_name),m.attr_email&&(R.email=m.attr_email);const M=Object.keys(R).length>0;c==="saml"?await t({protocol:"saml",domain_id:m.domain_id||void 0,idp_entity_id:m.idp_entity_id,idp_sso_url:m.idp_sso_url,idp_certificate:m.idp_certificate,jit_enabled:m.jit_enabled,...M&&{attribute_mapping:R}}):await t({protocol:"oidc",domain_id:m.domain_id||void 0,oidc_issuer_url:m.oidc_issuer_url,oidc_client_id:m.oidc_client_id,oidc_client_secret:m.oidc_client_secret,oidc_scopes:m.oidc_scopes,jit_enabled:m.jit_enabled,...M&&{attribute_mapping:R}})}finally{i(!1)}},E=async()=>{z(!0),y(null);const j=F=>F.includes("{")||F.includes("}"),R={},M={};if(c==="saml"?(m.idp_entity_id?j(m.idp_entity_id)?(M.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):M.entity_id_valid=!0:(M.entity_id_valid=!1,R.entity_id_valid="IdP Entity ID is required"),m.idp_sso_url?j(m.idp_sso_url)?(M.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):M.sso_url_valid=!0:(M.sso_url_valid=!1,R.sso_url_valid="IdP SSO URL is required"),m.idp_certificate?M.certificate_provided=!0:(M.certificate_provided=!1,R.certificate_provided="X.509 Certificate is required")):(m.oidc_issuer_url?j(m.oidc_issuer_url)?(M.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):M.issuer_url_valid=!0:(M.issuer_url_valid=!1,R.issuer_url_valid="Issuer URL is required"),m.oidc_client_id?j(m.oidc_client_id)?(M.client_id_valid=!1,R.client_id_valid="Client ID contains placeholder values - please replace with actual values"):M.client_id_valid=!0:(M.client_id_valid=!1,R.client_id_valid="Client ID is required")),Object.keys(R).length>0){y({success:!1,checks:M,errors:R}),z(!1);return}try{const F=c==="saml"?{protocol:"saml",idp_entity_id:m.idp_entity_id,idp_sso_url:m.idp_sso_url,idp_certificate:m.idp_certificate}:{protocol:"oidc",oidc_issuer_url:m.oidc_issuer_url,oidc_client_id:m.oidc_client_id,oidc_client_secret:m.oidc_client_secret},A=await(o==null?void 0:o(F));A&&y(A)}catch(F){y({success:!1,checks:{},errors:{general:"Test failed: "+F.message}})}finally{z(!1)}};return e.jsxs("form",{onSubmit:T,children:[u?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[u.logo?e.jsx(Nn,{src:u.logo,alt:u.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:u.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:u.protocol})]}),e.jsx("button",{type:"button",onClick:()=>f(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{children:"SAML Providers"}),e.jsx(Qi,{children:Ki.filter(j=>j.protocol==="saml").map(j=>e.jsxs(Xi,{type:"button",$selected:!1,onClick:()=>_(j),children:[j.logo?e.jsx(Nn,{src:j.logo,alt:j.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Ji,{children:j.name})]},j.id))}),e.jsx(Fn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Qi,{children:Ki.filter(j=>j.protocol==="oidc").map(j=>e.jsxs(Xi,{type:"button",$selected:!1,onClick:()=>_(j),children:[j.logo?e.jsx(Nn,{src:j.logo,alt:j.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Ji,{children:j.name})]},j.id))})]}),u&&e.jsxs(e.Fragment,{children:[e.jsxs(Zi,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:I}),e.jsx(br,{onClick:()=>S(I,"acs"),children:l==="acs"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:P}),e.jsx(br,{onClick:()=>S(P,"metadata"),children:l==="metadata"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:v}),e.jsx(br,{onClick:()=>S(v,"callback"),children:l==="callback"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Fn,{style:{margin:0},children:u?`${u.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[u&&u.docUrl&&e.jsxs("a",{href:u.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(zs,{size:12})," Docs"]}),e.jsx(Q,{type:"button",onClick:E,disabled:$||!u,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:$?e.jsx(Ee,{size:16}):"Test Connection"}),e.jsx(Q,{type:"submit",disabled:s||k.length===0||!u,style:{width:"auto",padding:"8px 16px"},children:s?e.jsx(Ee,{size:16}):"Create Connection"})]})]}),w&&(()=>{const j={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:w.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${w.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:w.success?"#10b981":"#ef4444"},children:w.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(w.checks).map(([R,M])=>{var F;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:M?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:M?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:j[R]||R.replace(/_/g," ").replace(/\b\w/g,A=>A.toUpperCase())}),((F=w.errors)==null?void 0:F[R])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:w.errors[R]})]})]},R)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!u&&e.jsxs(he,{children:[e.jsx(ae,{children:"Protocol *"}),e.jsxs(ea,{value:c,onChange:j=>h(j.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ae,{children:"Domain *"}),C?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):k.length===0?e.jsx(Zi,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(ea,{value:m.domain_id,onChange:j=>b({...m,domain_id:j.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),k.map(j=>e.jsx("option",{value:j.id,children:j.fqdn},j.id))]})]}),c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ae,{children:"IdP Entity ID *"}),e.jsx(ce,{type:"text",value:m.idp_entity_id,onChange:j=>b({...m,idp_entity_id:j.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"IdP SSO URL *"}),e.jsx(ce,{type:"url",value:m.idp_sso_url,onChange:j=>b({...m,idp_sso_url:j.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ae,{children:"X.509 Certificate *"}),e.jsx(cx,{value:m.idp_certificate,onChange:j=>b({...m,idp_certificate:j.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ae,{children:"Issuer URL *"}),e.jsx(ce,{type:"url",value:m.oidc_issuer_url,onChange:j=>b({...m,oidc_issuer_url:j.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Client ID *"}),e.jsx(ce,{type:"text",value:m.oidc_client_id,onChange:j=>b({...m,oidc_client_id:j.target.value}),placeholder:"your-client-id",required:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Client Secret *"}),e.jsx(ce,{type:"password",value:m.oidc_client_secret,onChange:j=>b({...m,oidc_client_secret:j.target.value}),placeholder:"your-client-secret",required:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Scopes"}),e.jsx(ce,{type:"text",value:m.oidc_scopes,onChange:j=>b({...m,oidc_scopes:j.target.value}),placeholder:"openid profile email"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:m.jit_enabled,onChange:j=>b({...m,jit_enabled:j.target.checked}),style:{width:"16px",height:"16px"}}),e.jsx("span",{style:{fontWeight:500,color:"var(--color-foreground)"},children:"Enable JIT Provisioning"})]}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px",marginLeft:"24px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px"},children:[e.jsxs("div",{onClick:()=>x(!g),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:g?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:g?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),g&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(he,{children:[e.jsx(ae,{children:"First Name Attribute"}),e.jsx(ce,{type:"text",value:m.attr_first_name,onChange:j=>b({...m,attr_first_name:j.target.value}),placeholder:c==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Last Name Attribute"}),e.jsx(ce,{type:"text",value:m.attr_last_name,onChange:j=>b({...m,attr_last_name:j.target.value}),placeholder:c==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Email Attribute"}),e.jsx(ce,{type:"text",value:m.attr_email,onChange:j=>b({...m,attr_email:j.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},ta=d.div`
2646
+ `,gx=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=Ze(),{deployment:n}=ve(),[s,a]=i.useState(!1),[p,f]=i.useState(null),[c,h]=i.useState("saml"),[l,u]=i.useState(null),[g,v]=i.useState(!1),[x,w]=i.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[$,S]=i.useState(!1),[k,P]=i.useState(null),{data:E=[],isLoading:z}=Fe("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(I=>I.verified),{revalidateOnFocus:!1}),y=C=>{f(C),h(C.protocol),C.protocol==="saml"?w(I=>{var M,F,L;return{...I,idp_entity_id:C.placeholders.entityId||"",idp_sso_url:C.placeholders.ssoUrl||"",attr_first_name:((M=C.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((F=C.attributeMapping)==null?void 0:F.last_name)||"",attr_email:((L=C.attributeMapping)==null?void 0:L.email)||""}}):w(I=>{var M,F,L;return{...I,oidc_issuer_url:C.placeholders.issuerUrl||"",oidc_scopes:C.placeholders.scopes||"openid profile email",attr_first_name:((M=C.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((F=C.attributeMapping)==null?void 0:F.last_name)||"",attr_email:((L=C.attributeMapping)==null?void 0:L.email)||""}})},m=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",b=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",_=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",j=(C,I)=>{navigator.clipboard.writeText(C),u(I),setTimeout(()=>u(null),2e3)},T=async C=>{C.preventDefault(),a(!0);try{const I={};x.attr_first_name&&(I.first_name=x.attr_first_name),x.attr_last_name&&(I.last_name=x.attr_last_name),x.attr_email&&(I.email=x.attr_email);const M=Object.keys(I).length>0;c==="saml"?await t({protocol:"saml",domain_id:x.domain_id||void 0,idp_entity_id:x.idp_entity_id,idp_sso_url:x.idp_sso_url,idp_certificate:x.idp_certificate,jit_enabled:x.jit_enabled,...M&&{attribute_mapping:I}}):await t({protocol:"oidc",domain_id:x.domain_id||void 0,oidc_issuer_url:x.oidc_issuer_url,oidc_client_id:x.oidc_client_id,oidc_client_secret:x.oidc_client_secret,oidc_scopes:x.oidc_scopes,jit_enabled:x.jit_enabled,...M&&{attribute_mapping:I}})}finally{a(!1)}},R=async()=>{S(!0),P(null);const C=F=>F.includes("{")||F.includes("}"),I={},M={};if(c==="saml"?(x.idp_entity_id?C(x.idp_entity_id)?(M.entity_id_valid=!1,I.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):M.entity_id_valid=!0:(M.entity_id_valid=!1,I.entity_id_valid="IdP Entity ID is required"),x.idp_sso_url?C(x.idp_sso_url)?(M.sso_url_valid=!1,I.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):M.sso_url_valid=!0:(M.sso_url_valid=!1,I.sso_url_valid="IdP SSO URL is required"),x.idp_certificate?M.certificate_provided=!0:(M.certificate_provided=!1,I.certificate_provided="X.509 Certificate is required")):(x.oidc_issuer_url?C(x.oidc_issuer_url)?(M.issuer_url_valid=!1,I.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):M.issuer_url_valid=!0:(M.issuer_url_valid=!1,I.issuer_url_valid="Issuer URL is required"),x.oidc_client_id?C(x.oidc_client_id)?(M.client_id_valid=!1,I.client_id_valid="Client ID contains placeholder values - please replace with actual values"):M.client_id_valid=!0:(M.client_id_valid=!1,I.client_id_valid="Client ID is required")),Object.keys(I).length>0){P({success:!1,checks:M,errors:I}),S(!1);return}try{const F=c==="saml"?{protocol:"saml",idp_entity_id:x.idp_entity_id,idp_sso_url:x.idp_sso_url,idp_certificate:x.idp_certificate}:{protocol:"oidc",oidc_issuer_url:x.oidc_issuer_url,oidc_client_id:x.oidc_client_id,oidc_client_secret:x.oidc_client_secret},L=await(o==null?void 0:o(F));L&&P(L)}catch(F){P({success:!1,checks:{},errors:{general:"Test failed: "+F.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:T,children:[p?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[p.logo?e.jsx(Nn,{src:p.logo,alt:p.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:p.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:p.protocol})]}),e.jsx("button",{type:"button",onClick:()=>f(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{children:"SAML Providers"}),e.jsx(Qa,{children:Ka.filter(C=>C.protocol==="saml").map(C=>e.jsxs(Xa,{type:"button",$selected:!1,onClick:()=>y(C),children:[C.logo?e.jsx(Nn,{src:C.logo,alt:C.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Ja,{children:C.name})]},C.id))}),e.jsx(Fn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Qa,{children:Ka.filter(C=>C.protocol==="oidc").map(C=>e.jsxs(Xa,{type:"button",$selected:!1,onClick:()=>y(C),children:[C.logo?e.jsx(Nn,{src:C.logo,alt:C.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Ja,{children:C.name})]},C.id))})]}),p&&e.jsxs(e.Fragment,{children:[e.jsxs(Za,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:_}),e.jsx(br,{onClick:()=>j(_,"acs"),children:l==="acs"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:b}),e.jsx(br,{onClick:()=>j(b,"metadata"),children:l==="metadata"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:m}),e.jsx(br,{onClick:()=>j(m,"callback"),children:l==="callback"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Fn,{style:{margin:0},children:p?`${p.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[p&&p.docUrl&&e.jsxs("a",{href:p.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(zs,{size:12})," Docs"]}),e.jsx(Q,{type:"button",onClick:R,disabled:$||!p,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:$?e.jsx(Ee,{size:16}):"Test Connection"}),e.jsx(Q,{type:"submit",disabled:s||E.length===0||!p,style:{width:"auto",padding:"8px 16px"},children:s?e.jsx(Ee,{size:16}):"Create Connection"})]})]}),k&&(()=>{const C={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:k.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${k.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:k.success?"#10b981":"#ef4444"},children:k.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(k.checks).map(([I,M])=>{var F;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:M?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:M?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:C[I]||I.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((F=k.errors)==null?void 0:F[I])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:k.errors[I]})]})]},I)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!p&&e.jsxs(he,{children:[e.jsx(ce,{children:"Protocol *"}),e.jsxs(ei,{value:c,onChange:C=>h(C.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ce,{children:"Domain *"}),z?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):E.length===0?e.jsx(Za,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(ei,{value:x.domain_id,onChange:C=>w({...x,domain_id:C.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),E.map(C=>e.jsx("option",{value:C.id,children:C.fqdn},C.id))]})]}),c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ce,{children:"IdP Entity ID *"}),e.jsx(le,{type:"text",value:x.idp_entity_id,onChange:C=>w({...x,idp_entity_id:C.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"IdP SSO URL *"}),e.jsx(le,{type:"url",value:x.idp_sso_url,onChange:C=>w({...x,idp_sso_url:C.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ce,{children:"X.509 Certificate *"}),e.jsx(cx,{value:x.idp_certificate,onChange:C=>w({...x,idp_certificate:C.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Issuer URL *"}),e.jsx(le,{type:"url",value:x.oidc_issuer_url,onChange:C=>w({...x,oidc_issuer_url:C.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Client ID *"}),e.jsx(le,{type:"text",value:x.oidc_client_id,onChange:C=>w({...x,oidc_client_id:C.target.value}),placeholder:"your-client-id",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Client Secret *"}),e.jsx(le,{type:"password",value:x.oidc_client_secret,onChange:C=>w({...x,oidc_client_secret:C.target.value}),placeholder:"your-client-secret",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Scopes"}),e.jsx(le,{type:"text",value:x.oidc_scopes,onChange:C=>w({...x,oidc_scopes:C.target.value}),placeholder:"openid profile email"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x.jit_enabled,onChange:C=>w({...x,jit_enabled:C.target.checked}),style:{width:"16px",height:"16px"}}),e.jsx("span",{style:{fontWeight:500,color:"var(--color-foreground)"},children:"Enable JIT Provisioning"})]}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px",marginLeft:"24px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px"},children:[e.jsxs("div",{onClick:()=>v(!g),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:g?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:g?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),g&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"First Name Attribute"}),e.jsx(le,{type:"text",value:x.attr_first_name,onChange:C=>w({...x,attr_first_name:C.target.value}),placeholder:c==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Last Name Attribute"}),e.jsx(le,{type:"text",value:x.attr_last_name,onChange:C=>w({...x,attr_last_name:C.target.value}),placeholder:c==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Email Attribute"}),e.jsx(le,{type:"text",value:x.attr_email,onChange:C=>w({...x,attr_email:C.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},ti=d.div`
2647
2647
  * {
2648
2648
  box-sizing: border-box;
2649
2649
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -2745,9 +2745,9 @@ cursor: pointer;
2745
2745
  flex-wrap: wrap;
2746
2746
  gap: 12px;
2747
2747
  margin-bottom: 24px;
2748
- `,bx=()=>{var M,F,A,B;const{activeOrganization:t,loading:r}=Ze(),{switchOrganization:o,refetch:n}=Ue(),{workspaces:s}=St(),{deployment:i}=ve(),{deleteOrganization:u,updateOrganization:f}=Yo(),{toast:c}=He(),[h,l]=a.useState((t==null?void 0:t.name)||""),[p,g]=a.useState((t==null?void 0:t.description)||""),[x,m]=a.useState((t==null?void 0:t.image_url)||null),b=a.useRef(null),[$,z]=a.useState(!1),[w,y]=a.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[k,C]=a.useState(""),[_,v]=a.useState(!1),[P,I]=a.useState(!1),S=a.useCallback(async()=>{if(!(!t||$))try{z(!0),await f(t,{name:h,description:p}),c("Changes saved","info")}catch(O){const L=O.message||"Failed to save changes. Please try again.";c(L,"error")}finally{z(!1)}},[t,h,p,x,w,f,c]);a.useEffect(()=>{var O;t&&(l(t.name||""),g(t.description||""),m(t.image_url||null),y({allowed_ips:((O=t.whitelisted_ips)==null?void 0:O.join(`
2749
- `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const T=a.useMemo(()=>s.filter(L=>L.organization.id===(t==null?void 0:t.id)),[s,t==null?void 0:t.id]),E=async()=>{if(!(!t||k!==t.name))try{v(!0),await o(""),await u(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{v(!1),C("")}};if(a.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const j=O=>{var L;if((L=O.target.files)!=null&&L[0]){const X=O.target.files[0];if(X.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!X.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&URL.revokeObjectURL(x),m(URL.createObjectURL(X)),setTimeout(()=>S(),100)}},R=()=>{b.current&&b.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:R,onMouseEnter:O=>{O.currentTarget.style.borderColor="var(--color-primary)",O.currentTarget.style.transform="scale(1.02)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--color-border)",O.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:b,style:{display:"none"},accept:"image/*",onChange:j,"aria-label":"Upload organization logo"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your organization"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var O;return(O=b.current)==null?void 0:O.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Ur,{size:14}),x?"Change":"Upload"]}),e.jsxs(Q,{onClick:()=>{m(null),b.current&&(b.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Hr,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your organization"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"name",children:"Organization Name"}),e.jsx(ce,{id:"name",type:"text",value:h,onChange:O=>l(O.target.value),onBlur:S,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"description",children:"Description"}),e.jsx(ce,{id:"description",as:"textarea",value:p,onChange:O=>g(O.target.value),onBlur:S,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),((M=i==null?void 0:i.b2b_settings)==null?void 0:M.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ae,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(Cr,{checked:w.mfa_required,onChange:()=>{y(O=>({...O,mfa_required:!O.mfa_required})),setTimeout(()=>S(),100)}})]}),((F=i==null?void 0:i.b2b_settings)==null?void 0:F.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ae,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(Cr,{checked:w.ip_restrictions,onChange:()=>{y(O=>({...O,ip_restrictions:!O.ip_restrictions})),setTimeout(()=>S(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),w.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(ce,{id:"allowed_ips",as:"textarea",value:w.allowed_ips,onChange:O=>y(L=>({...L,allowed_ips:O.target.value})),onBlur:S,placeholder:`192.168.1.1
2750
- 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((A=i==null?void 0:i.b2b_settings)==null?void 0:A.workspaces_enabled)&&T.length>0&&e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Is,{options:T.map(O=>({value:O.id,label:O.name})),value:w.default_workspace_id,onChange:O=>{y(L=>({...L,default_workspace_id:O})),setTimeout(()=>S(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((B=i==null?void 0:i.b2b_settings)==null?void 0:B.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:P?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this organization, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{P?(I(!1),C("")):I(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:P?"Cancel":"Delete"})]}),P&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(ce,{id:"confirm_name",type:"text",value:k,onChange:O=>C(O.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Q,{onClick:E,disabled:k!==(t==null?void 0:t.name)||_,style:{background:k===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:k===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:k===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:k===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:_?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})]})})},ra=d.span`
2748
+ `,bx=()=>{var M,F,L,B;const{activeOrganization:t,loading:r}=Ze(),{switchOrganization:o,refetch:n}=Ue(),{workspaces:s}=Pt(),{deployment:a}=ve(),{deleteOrganization:p,updateOrganization:f}=Yo(),{toast:c}=He(),[h,l]=i.useState((t==null?void 0:t.name)||""),[u,g]=i.useState((t==null?void 0:t.description)||""),[v,x]=i.useState((t==null?void 0:t.image_url)||null),w=i.useRef(null),[$,S]=i.useState(!1),[k,P]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[E,z]=i.useState(""),[y,m]=i.useState(!1),[b,_]=i.useState(!1),j=i.useCallback(async()=>{if(!(!t||$))try{S(!0),await f(t,{name:h,description:u}),c("Changes saved","info")}catch(O){const A=O.message||"Failed to save changes. Please try again.";c(A,"error")}finally{S(!1)}},[t,h,u,v,k,f,c]);i.useEffect(()=>{var O;t&&(l(t.name||""),g(t.description||""),x(t.image_url||null),P({allowed_ips:((O=t.whitelisted_ips)==null?void 0:O.join(`
2749
+ `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const T=i.useMemo(()=>s.filter(A=>A.organization.id===(t==null?void 0:t.id)),[s,t==null?void 0:t.id]),R=async()=>{if(!(!t||E!==t.name))try{m(!0),await o(""),await p(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{m(!1),z("")}};if(i.useEffect(()=>()=>{v&&URL.revokeObjectURL(v)},[v]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const C=O=>{var A;if((A=O.target.files)!=null&&A[0]){const X=O.target.files[0];if(X.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!X.type.startsWith("image/")){c("Please select a valid image file","error");return}v&&URL.revokeObjectURL(v),x(URL.createObjectURL(X)),setTimeout(()=>j(),100)}},I=()=>{w.current&&w.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:v?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:I,onMouseEnter:O=>{O.currentTarget.style.borderColor="var(--color-primary)",O.currentTarget.style.transform="scale(1.02)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--color-border)",O.currentTarget.style.transform="scale(1)"},children:[v?e.jsx("img",{src:v,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:w,style:{display:"none"},accept:"image/*",onChange:C,"aria-label":"Upload organization logo"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your organization"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var O;return(O=w.current)==null?void 0:O.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Ur,{size:14}),v?"Change":"Upload"]}),e.jsxs(Q,{onClick:()=>{x(null),w.current&&(w.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Hr,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your organization"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"name",children:"Organization Name"}),e.jsx(le,{id:"name",type:"text",value:h,onChange:O=>l(O.target.value),onBlur:j,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"description",children:"Description"}),e.jsx(le,{id:"description",as:"textarea",value:u,onChange:O=>g(O.target.value),onBlur:j,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),((M=a==null?void 0:a.b2b_settings)==null?void 0:M.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(Cr,{checked:k.mfa_required,onChange:()=>{P(O=>({...O,mfa_required:!O.mfa_required})),setTimeout(()=>j(),100)}})]}),((F=a==null?void 0:a.b2b_settings)==null?void 0:F.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(Cr,{checked:k.ip_restrictions,onChange:()=>{P(O=>({...O,ip_restrictions:!O.ip_restrictions})),setTimeout(()=>j(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),k.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(le,{id:"allowed_ips",as:"textarea",value:k.allowed_ips,onChange:O=>P(A=>({...A,allowed_ips:O.target.value})),onBlur:j,placeholder:`192.168.1.1
2750
+ 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((L=a==null?void 0:a.b2b_settings)==null?void 0:L.workspaces_enabled)&&T.length>0&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Is,{options:T.map(O=>({value:O.id,label:O.name})),value:k.default_workspace_id,onChange:O=>{P(A=>({...A,default_workspace_id:O})),setTimeout(()=>j(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((B=a==null?void 0:a.b2b_settings)==null?void 0:B.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:b?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this organization, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{b?(_(!1),z("")):_(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:b?"Cancel":"Delete"})]}),b&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(le,{id:"confirm_name",type:"text",value:E,onChange:O=>z(O.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Q,{onClick:R,disabled:E!==(t==null?void 0:t.name)||y,style:{background:E===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:E===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:E===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:E===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:y?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})]})})},ri=d.span`
2751
2751
  background: var(--color-primary-background);
2752
2752
  color: var(--color-primary);
2753
2753
  padding: 4px 8px;
@@ -2784,7 +2784,7 @@ cursor: pointer;
2784
2784
  opacity: 0.5;
2785
2785
  cursor: not-allowed;
2786
2786
  }
2787
- `,yx=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=Ze(),s=a.useRef(null),[i,u]=a.useState(null),{data:f=[],isLoading:c,mutate:h}=Be(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((I,S)=>({...I,verified:I.verified!==void 0?I.verified:S%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),l=f,[p,g]=a.useState(!1),[x,m]=a.useState(null),[b,$]=a.useState(""),[z,w]=a.useState(null),y=a.useRef(null),k=a.useRef({}),C=a.useMemo(()=>{let P=l;if(b.trim()!==""){const I=b.toLowerCase();P=P.filter(S=>S.fqdn.toLowerCase().includes(I))}return P},[l,b]),_=async P=>{await n(P),h()},v=async P=>{m(P)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Rl,{children:[e.jsx(zt,{value:b,onChange:$,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(Q,{ref:y,onClick:()=>g(!p),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),p&&e.jsx(qi,{onClose:()=>{g(!1),h()},triggerRef:y})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),C!=null&&C.length?e.jsxs(ht,{ref:s,children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Domain"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{children:"Date Added"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:C.map(P=>e.jsxs(Ne,{children:[e.jsx(Me,{children:P.fqdn}),e.jsx(Me,{children:P.verified?e.jsx(ra,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(ra,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(ut,{size:9})," Pending Verification"]})}),e.jsx(Me,{children:new Date(P.created_at).toLocaleDateString()}),e.jsx(mt,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(nt,{style:{marginLeft:"auto"},open:z===P.id,openChange:I=>w(I?P.id:null),children:[e.jsx(it,{children:e.jsx(Rs,{ref:I=>{k.current[P.id]=I},children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{v(P.id),w(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:P.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Te,{onClick:()=>{w(null),navigator.clipboard.writeText(P.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jt,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Te,{onClick:()=>{window.open(`https://${P.fqdn}`,"_blank"),w(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(zs,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>{w(null),u(P.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),i===P.id&&e.jsx(Yr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>_(P),onCancel:()=>u(null)}),x===P.id&&e.jsx(qi,{domain:P,onClose:()=>m(null),triggerRef:{current:k.current[P.id]}})]})})]},P.id))})]}):e.jsx(at,{title:b!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},wx=d.div`
2787
+ `,yx=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=Ze(),s=i.useRef(null),[a,p]=i.useState(null),{data:f=[],isLoading:c,mutate:h}=Fe(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((_,j)=>({..._,verified:_.verified!==void 0?_.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),l=f,[u,g]=i.useState(!1),[v,x]=i.useState(null),[w,$]=i.useState(""),[S,k]=i.useState(null),P=i.useRef(null),E=i.useRef({}),z=i.useMemo(()=>{let b=l;if(w.trim()!==""){const _=w.toLowerCase();b=b.filter(j=>j.fqdn.toLowerCase().includes(_))}return b},[l,w]),y=async b=>{await n(b),h()},m=async b=>{x(b)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Rl,{children:[e.jsx(St,{value:w,onChange:$,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(Q,{ref:P,onClick:()=>g(!u),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),u&&e.jsx(qa,{onClose:()=>{g(!1),h()},triggerRef:P})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),z!=null&&z.length?e.jsxs(ht,{ref:s,children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Domain"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{children:"Date Added"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:z.map(b=>e.jsxs(Ne,{children:[e.jsx(Me,{children:b.fqdn}),e.jsx(Me,{children:b.verified?e.jsx(ri,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(ri,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(ut,{size:9})," Pending Verification"]})}),e.jsx(Me,{children:new Date(b.created_at).toLocaleDateString()}),e.jsx(mt,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(nt,{style:{marginLeft:"auto"},open:S===b.id,openChange:_=>k(_?b.id:null),children:[e.jsx(at,{children:e.jsx(Rs,{ref:_=>{E.current[b.id]=_},children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{m(b.id),k(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:b.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Te,{onClick:()=>{k(null),navigator.clipboard.writeText(b.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jt,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Te,{onClick:()=>{window.open(`https://${b.fqdn}`,"_blank"),k(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(zs,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>{k(null),p(b.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),a===b.id&&e.jsx(Yr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>y(b),onCancel:()=>p(null)}),v===b.id&&e.jsx(qa,{domain:b,onClose:()=>x(null),triggerRef:{current:E.current[b.id]}})]})})]},b.id))})]}):e.jsx(it,{title:w!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},wx=d.div`
2788
2788
  width: 40px;
2789
2789
  height: 40px;
2790
2790
  border-radius: 50%;
@@ -2796,7 +2796,7 @@ cursor: pointer;
2796
2796
  font-weight: 400;
2797
2797
  font-size: 14px;
2798
2798
  overflow: hidden;
2799
- `,jx=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:s,removeMemberRole:i,removeMember:u}=Ze(),{session:f}=Ue(),{toast:c}=He(),[h,l]=a.useState(""),[p,g]=a.useState(!1),x=a.useRef(null),{data:m=[],isLoading:b,mutate:$}=Be(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:z=[],isLoading:w}=Be(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),y=z,k=a.useMemo(()=>h?m.filter(S=>{var F;const T=S.user;if(!T)return!1;const E=T.first_name||"",j=T.last_name||"",R=((F=T.primary_email_address)==null?void 0:F.email)||"";return`${E} ${j}`.trim().toLowerCase().includes(h.toLowerCase())||R.toLowerCase().includes(h.toLowerCase())}):m,[m,h]),C=async(S,T,E)=>{try{E?(await i(S,T),c("Role removed successfully","info")):(await s(S,T),c("Role added successfully","info")),$()}catch(j){const R=j.message||"Failed to update role. Please try again.";c(R,"error")}},_=(S="",T="")=>`${S[0]||""}${T[0]||""}`.toUpperCase(),v=(S,T)=>{var E;return((E=S.roles)==null?void 0:E.some(j=>j.id===T))||!1},P=async S=>{try{await u(S),$(),c("Member removed successfully","info")}catch(T){const E=T.message||"Failed to remove member. Please try again.";c(E,"error")}},I=()=>{g(!1),$(),c("Invitation sent successfully","info")};return r||b||w?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(zt,{value:h,onChange:l,placeholder:"Search members..."})}),e.jsx(Q,{ref:x,onClick:()=>g(!p),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),p&&e.jsx($l,{onClose:()=>g(!1),onSuccess:I,roles:y,triggerRef:x}),k.length===0?e.jsx(at,{title:h?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Roles"})]})}),e.jsx(gt,{children:k.map(S=>{var R,M;const T=S.roles||[],E=S.user,j=(E==null?void 0:E.id)===((R=f==null?void 0:f.active_signin)==null?void 0:R.user_id);return e.jsxs(Ne,{children:[e.jsx(El,{children:e.jsxs("div",{children:[e.jsx(wx,{children:E!=null&&E.profile_picture_url?e.jsx("img",{src:E.profile_picture_url,alt:`${E.first_name||""} ${E.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):_(E==null?void 0:E.first_name,E==null?void 0:E.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var A;if(!E)return"Unknown User";const F=`${E.first_name||""} ${E.last_name||""}`.trim();return F||((A=E.primary_email_address)==null?void 0:A.email)||"Unknown User"})()}),j&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(M=E==null?void 0:E.primary_email_address)==null?void 0:M.email})]})]})}),e.jsx(Me,{children:new Date(S.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsxs(Q,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:T.length>0?T[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[y.map(F=>{const A=v(S,F.id);return e.jsx(Te,{onClick:()=>C(S,F,A),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:F.name}),A&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},F.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>P(S),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},S.id)})})]})]})},_x=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:s,resendInvitation:i}=Ze(),{toast:u}=He(),[f,c]=a.useState(!1),[h,l]=a.useState(""),p=a.useRef(null),{data:g=[],isLoading:x,mutate:m}=Be(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:b=[],isLoading:$}=Be(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),z=b,w=a.useMemo(()=>h?g.filter(_=>_.email.toLowerCase().includes(h.toLowerCase())):g,[g,h]),y=()=>{u("Invitation sent successfully","info"),m(),c(!1)},k=async _=>{try{await s(_),m(),u("Invitation cancelled successfully","info")}catch(v){const P=v.message||"Failed to cancel invitation. Please try again.";u(P,"error")}},C=async _=>{try{await i(_),u("Invitation resent successfully","info")}catch(v){const P=v.message||"Failed to resend invitation. Please try again.";u(P,"error")}};return r||x||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(zt,{value:h,onChange:l,placeholder:"Search invitations..."})}),e.jsx(Q,{ref:p,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx($l,{onClose:()=>c(!1),onSuccess:y,roles:z,triggerRef:p}),w.length===0?e.jsx(at,{title:h?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:w.map(_=>{var v;return e.jsxs(Ne,{children:[e.jsx(Me,{children:_.email}),e.jsx(Me,{children:((v=_.initial_organization_role)==null?void 0:v.name)||"No role"}),e.jsx(Me,{children:new Date(_.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsx(Rs,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>C(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(on,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>k(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},_.id)})})]})]})},kx=()=>{var _;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=Ze(),{deployment:s}=ve(),[i,u]=a.useState({isOpen:!1}),[f,c]=a.useState(null),[h,l]=a.useState(null),[p,g]=a.useState(""),[x,m]=a.useState(null),b=a.useRef(null),{data:$=[],isLoading:z,mutate:w}=Be(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),y=a.useMemo(()=>p?$.filter(v=>v.name.toLowerCase().includes(p.toLowerCase())):$,[$,p]),k=async v=>{try{v.id?(await new Promise(P=>setTimeout(P,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(P=>setTimeout(P,1e3)),c({text:"Role created successfully",type:"success"})),u({isOpen:!1}),w()}catch(P){const I=(P==null?void 0:P.message)||(v.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");v.id?c({text:I,type:"error"}):c({text:I,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},C=async v=>{try{await n(v),w()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||z?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(ut,{size:16}),f.text]}),e.jsxs(Rl,{children:[e.jsx(zt,{placeholder:"Search roles",onChange:g,value:p}),((_=s==null?void 0:s.b2b_settings)==null?void 0:_.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(Q,{ref:b,onClick:()=>u({isOpen:!i.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),i.isOpen&&!i.role&&e.jsx(Yi,{role:i.role,onClose:()=>u({isOpen:!1}),onSuccess:k,triggerRef:b})]})]}),y.length===0?e.jsx(at,{title:p?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:y.map(v=>{var P;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:v.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:v.permissions.join(", ")}),e.jsx(mt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:h===v.id,openChange:I=>l(I?v.id:null),children:[e.jsx(it,{children:e.jsx(Rs,{disabled:!v.organization_id,"data-role-dropdown-trigger":v.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{l(null),u({isOpen:!0,role:v})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{l(null),m(v.id)},children:"Remove Role"})]})]}),x===v.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>C(v),onCancel:()=>m(null)}),i.isOpen&&((P=i.role)==null?void 0:P.id)===v.id&&e.jsx(Yi,{role:i.role,onClose:()=>{u({isOpen:!1}),l(null)},onSuccess:k})]})})]},v.id)})})]})]})},Tl=()=>{const{loading:t,activeOrganization:r}=Ze(),[o,n]=a.useState("general"),[s,i]=a.useState(null),[u,f]=a.useState("info"),c=a.useCallback((h,l="info")=>{i(h),f(l),setTimeout(()=>i(null),3e3)},[i]);return t?e.jsx(Bn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):r?e.jsx(ta,{children:e.jsx(Ps.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Bn,{children:[e.jsx(mx,{children:e.jsxs(xx,{children:[e.jsx(hr,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(fr,{children:[e.jsx(er,{size:16}),"General"]})}),e.jsx(hr,{$isActive:o==="domains",onClick:()=>n("domains"),children:e.jsxs(fr,{children:[e.jsx(ch,{size:16}),"Domains"]})}),e.jsx(hr,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(fr,{children:[e.jsx(Uo,{size:16}),"Members"]})}),e.jsx(hr,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(fr,{children:[e.jsx(on,{size:16}),"Invitations"]})}),e.jsx(hr,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"Roles"]})}),e.jsx(hr,{$isActive:o==="sso",onClick:()=>n("sso"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"SSO"]})})]})}),e.jsxs(vx,{children:[o==="general"&&e.jsx(bx,{}),o==="domains"&&e.jsx(yx,{}),o==="members"&&e.jsx(jx,{}),o==="invitations"&&e.jsx(_x,{}),o==="roles"&&e.jsx(kx,{}),o==="sso"&&e.jsx(lx,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):e.jsx(ta,{children:e.jsx(Bn,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(Ur,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(Hl,{})]})})})},Cx=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:i,customContent:u,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),u||f||e.jsx(Tl,{}),i&&e.jsx(ke.Footer,{children:i})]})})}),Sx=d.div`
2799
+ `,jx=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:s,removeMemberRole:a,removeMember:p}=Ze(),{session:f}=Ue(),{toast:c}=He(),[h,l]=i.useState(""),[u,g]=i.useState(!1),v=i.useRef(null),{data:x=[],isLoading:w,mutate:$}=Fe(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:S=[],isLoading:k}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),P=S,E=i.useMemo(()=>h?x.filter(j=>{var F;const T=j.user;if(!T)return!1;const R=T.first_name||"",C=T.last_name||"",I=((F=T.primary_email_address)==null?void 0:F.email)||"";return`${R} ${C}`.trim().toLowerCase().includes(h.toLowerCase())||I.toLowerCase().includes(h.toLowerCase())}):x,[x,h]),z=async(j,T,R)=>{try{R?(await a(j,T),c("Role removed successfully","info")):(await s(j,T),c("Role added successfully","info")),$()}catch(C){const I=C.message||"Failed to update role. Please try again.";c(I,"error")}},y=(j="",T="")=>`${j[0]||""}${T[0]||""}`.toUpperCase(),m=(j,T)=>{var R;return((R=j.roles)==null?void 0:R.some(C=>C.id===T))||!1},b=async j=>{try{await p(j),$(),c("Member removed successfully","info")}catch(T){const R=T.message||"Failed to remove member. Please try again.";c(R,"error")}},_=()=>{g(!1),$(),c("Invitation sent successfully","info")};return r||w||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(St,{value:h,onChange:l,placeholder:"Search members..."})}),e.jsx(Q,{ref:v,onClick:()=>g(!u),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),u&&e.jsx($l,{onClose:()=>g(!1),onSuccess:_,roles:P,triggerRef:v}),E.length===0?e.jsx(it,{title:h?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Roles"})]})}),e.jsx(gt,{children:E.map(j=>{var I,M;const T=j.roles||[],R=j.user,C=(R==null?void 0:R.id)===((I=f==null?void 0:f.active_signin)==null?void 0:I.user_id);return e.jsxs(Ne,{children:[e.jsx(El,{children:e.jsxs("div",{children:[e.jsx(wx,{children:R!=null&&R.profile_picture_url?e.jsx("img",{src:R.profile_picture_url,alt:`${R.first_name||""} ${R.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):y(R==null?void 0:R.first_name,R==null?void 0:R.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var L;if(!R)return"Unknown User";const F=`${R.first_name||""} ${R.last_name||""}`.trim();return F||((L=R.primary_email_address)==null?void 0:L.email)||"Unknown User"})()}),C&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(M=R==null?void 0:R.primary_email_address)==null?void 0:M.email})]})]})}),e.jsx(Me,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(Q,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:T.length>0?T[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[P.map(F=>{const L=m(j,F.id);return e.jsx(Te,{onClick:()=>z(j,F,L),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:F.name}),L&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},F.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>b(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},_x=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:s,resendInvitation:a}=Ze(),{toast:p}=He(),[f,c]=i.useState(!1),[h,l]=i.useState(""),u=i.useRef(null),{data:g=[],isLoading:v,mutate:x}=Fe(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:w=[],isLoading:$}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),S=w,k=i.useMemo(()=>h?g.filter(y=>y.email.toLowerCase().includes(h.toLowerCase())):g,[g,h]),P=()=>{p("Invitation sent successfully","info"),x(),c(!1)},E=async y=>{try{await s(y),x(),p("Invitation cancelled successfully","info")}catch(m){const b=m.message||"Failed to cancel invitation. Please try again.";p(b,"error")}},z=async y=>{try{await a(y),p("Invitation resent successfully","info")}catch(m){const b=m.message||"Failed to resend invitation. Please try again.";p(b,"error")}};return r||v||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(St,{value:h,onChange:l,placeholder:"Search invitations..."})}),e.jsx(Q,{ref:u,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx($l,{onClose:()=>c(!1),onSuccess:P,roles:S,triggerRef:u}),k.length===0?e.jsx(it,{title:h?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:k.map(y=>{var m;return e.jsxs(Ne,{children:[e.jsx(Me,{children:y.email}),e.jsx(Me,{children:((m=y.initial_organization_role)==null?void 0:m.name)||"No role"}),e.jsx(Me,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsx(Rs,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>z(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(on,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>E(y),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},y.id)})})]})]})},kx=()=>{var y;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=Ze(),{deployment:s}=ve(),[a,p]=i.useState({isOpen:!1}),[f,c]=i.useState(null),[h,l]=i.useState(null),[u,g]=i.useState(""),[v,x]=i.useState(null),w=i.useRef(null),{data:$=[],isLoading:S,mutate:k}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),P=i.useMemo(()=>u?$.filter(m=>m.name.toLowerCase().includes(u.toLowerCase())):$,[$,u]),E=async m=>{try{m.id?(await new Promise(b=>setTimeout(b,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(b=>setTimeout(b,1e3)),c({text:"Role created successfully",type:"success"})),p({isOpen:!1}),k()}catch(b){const _=(b==null?void 0:b.message)||(m.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");m.id?c({text:_,type:"error"}):c({text:_,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},z=async m=>{try{await n(m),k()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(ut,{size:16}),f.text]}),e.jsxs(Rl,{children:[e.jsx(St,{placeholder:"Search roles",onChange:g,value:u}),((y=s==null?void 0:s.b2b_settings)==null?void 0:y.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(Q,{ref:w,onClick:()=>p({isOpen:!a.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),a.isOpen&&!a.role&&e.jsx(Ya,{role:a.role,onClose:()=>p({isOpen:!1}),onSuccess:E,triggerRef:w})]})]}),P.length===0?e.jsx(it,{title:u?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:P.map(m=>{var b;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:m.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:m.permissions.join(", ")}),e.jsx(mt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:h===m.id,openChange:_=>l(_?m.id:null),children:[e.jsx(at,{children:e.jsx(Rs,{disabled:!m.organization_id,"data-role-dropdown-trigger":m.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{l(null),p({isOpen:!0,role:m})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{l(null),x(m.id)},children:"Remove Role"})]})]}),v===m.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>z(m),onCancel:()=>x(null)}),a.isOpen&&((b=a.role)==null?void 0:b.id)===m.id&&e.jsx(Ya,{role:a.role,onClose:()=>{p({isOpen:!1}),l(null)},onSuccess:E})]})})]},m.id)})})]})]})},Tl=()=>{const{loading:t,activeOrganization:r}=Ze(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[p,f]=i.useState("info"),c=i.useCallback((h,l="info")=>{a(h),f(l),setTimeout(()=>a(null),3e3)},[a]);return t?e.jsx(Bn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):r?e.jsx(ti,{children:e.jsx(Ps.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Bn,{children:[e.jsx(mx,{children:e.jsxs(xx,{children:[e.jsx(hr,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(fr,{children:[e.jsx(er,{size:16}),"General"]})}),e.jsx(hr,{$isActive:o==="domains",onClick:()=>n("domains"),children:e.jsxs(fr,{children:[e.jsx(ch,{size:16}),"Domains"]})}),e.jsx(hr,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(fr,{children:[e.jsx(Uo,{size:16}),"Members"]})}),e.jsx(hr,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(fr,{children:[e.jsx(on,{size:16}),"Invitations"]})}),e.jsx(hr,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"Roles"]})}),e.jsx(hr,{$isActive:o==="sso",onClick:()=>n("sso"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"SSO"]})})]})}),e.jsxs(vx,{children:[o==="general"&&e.jsx(bx,{}),o==="domains"&&e.jsx(yx,{}),o==="members"&&e.jsx(jx,{}),o==="invitations"&&e.jsx(_x,{}),o==="roles"&&e.jsx(kx,{}),o==="sso"&&e.jsx(lx,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):e.jsx(ti,{children:e.jsx(Bn,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(Ur,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(Hl,{})]})})})},Cx=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:p,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),p||f||e.jsx(Tl,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Sx=d.div`
2800
2800
  display: flex;
2801
2801
  height: 100%;
2802
2802
  min-height: 400px;
@@ -3052,7 +3052,7 @@ cursor: pointer;
3052
3052
  cursor: not-allowed;
3053
3053
  opacity: 0.5;
3054
3054
  }
3055
- `,oa=d.div`
3055
+ `,oi=d.div`
3056
3056
  width: 20px;
3057
3057
  height: 20px;
3058
3058
  border-radius: 50%;
@@ -3065,7 +3065,7 @@ cursor: pointer;
3065
3065
  font-weight: 600;
3066
3066
  color: var(--color-secondary-text);
3067
3067
  flex-shrink: 0;
3068
- `,na=d.img`
3068
+ `,ni=d.img`
3069
3069
  width: 100%;
3070
3070
  height: 100%;
3071
3071
  object-fit: cover;
@@ -3087,7 +3087,7 @@ cursor: pointer;
3087
3087
  align-items: center;
3088
3088
  justify-content: center;
3089
3089
  color: var(--color-primary);
3090
- `,Ts=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var R;const[s,i]=a.useState(""),[u,f]=a.useState(""),[c,h]=a.useState(),[l,p]=a.useState(null),[g,x]=a.useState(!1),[m,b]=a.useState(!1),[$,z]=a.useState(t),w=a.useRef(null),y=a.useRef(null),{toast:k}=He(),{createWorkspace:C}=St(),{organizationMemberships:_}=Ct(),v=(R=_==null?void 0:_.find(M=>M.organization.id===$))==null?void 0:R.organization,P=M=>{if(M.target.files&&M.target.files[0]){const F=M.target.files[0];if(F.size>2*1024*1024){k("File size cannot exceed 2MB","error");return}if(!F.type.startsWith("image/")){k("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),h(F),p(URL.createObjectURL(F))}},I=()=>{var M;(M=w.current)==null||M.click()},S=M=>M.split(" ").map(F=>F[0]).join("").toUpperCase().slice(0,2)||"W",T=M=>M.trim().replace(/[<>\"'&]/g,""),E=M=>M.length>=2&&M.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(M),j=async()=>{const M=T(s),F=T(u);if(!M||!$){k("Please enter a workspace name","error");return}if(!E(M)){k("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(F.length>500){k("Description must be less than 500 characters","error");return}x(!0);try{const A=await C($,M,c,F);r==null||r(A)}catch(A){const B=A.message||"Failed to create workspace. Please try again.";k(B,"error")}finally{x(!1)}};return a.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]),a.useEffect(()=>{const M=F=>{y.current&&!y.current.contains(F.target)&&b(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]),e.jsx(ge,{children:e.jsxs(Sx,{children:[e.jsxs(zx,{children:[e.jsxs(Ml,{hasImage:!!l,onClick:I,children:[l?e.jsx(Ex,{src:l,alt:"Workspace logo"}):e.jsx(Ix,{children:S(s||"W")}),e.jsx(Wx,{children:e.jsx(Vx,{children:"Upload Logo"})})]}),e.jsx(Ux,{type:"file",ref:w,onChange:P,accept:"image/png, image/jpeg, image/gif",disabled:g}),e.jsx(Px,{children:"Create new workspace"}),e.jsx(Rx,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs($x,{children:[e.jsxs(Tx,{children:[e.jsx(Mx,{children:"Choose your workspace name"}),e.jsx(Ox,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(Ax,{children:[e.jsxs(Un,{children:[e.jsx(Wn,{children:"Organization"}),e.jsxs(Gx,{ref:y,children:[e.jsxs(Hx,{type:"button",onClick:()=>b(!m),disabled:g,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(oa,{children:v!=null&&v.image_url?e.jsx(na,{src:v.image_url,alt:v.name}):S((v==null?void 0:v.name)||"O").charAt(0)}),e.jsx("span",{children:(v==null?void 0:v.name)||"Select organization"})]}),e.jsx(or,{size:16,style:{color:"var(--color-secondary-text)"}})]}),m&&e.jsxs(qx,{children:[_==null?void 0:_.map(M=>e.jsxs(Ol,{onClick:()=>{z(M.organization.id),b(!1)},children:[e.jsx(oa,{children:M.organization.image_url?e.jsx(na,{src:M.organization.image_url,alt:M.organization.name}):S(M.organization.name).charAt(0)}),e.jsx("span",{children:M.organization.name})]},M.organization.id)),e.jsxs(Yx,{onClick:()=>{b(!1),n==null||n()},children:[e.jsx(Zx,{children:e.jsx(Ke,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Workspace name"}),e.jsx(Lx,{type:"text",value:s,onChange:M=>i(M.target.value),placeholder:"Workspace Name",disabled:g})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Description (optional)"}),e.jsx(Dx,{value:u,onChange:M=>f(M.target.value),placeholder:"What is this workspace for?",disabled:g})]})]}),e.jsxs(Nx,{children:[o?e.jsxs(Fx,{onClick:o,disabled:g,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Bx,{onClick:j,disabled:g||!s.trim(),children:g?"Creating...":"Create"})]})]})]})})},Al=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[s,i]=a.useState(!1),[u,f]=a.useState(n),{refetch:c,organizationMemberships:h}=Ct(),l=()=>{o==null||o(),r==null||r()},p=()=>{i(!0)},g=async()=>{await c(),setTimeout(()=>{if(h&&h.length>0){const x=h[h.length-1];f(x.organization.id)}i(!1)},500)};return e.jsx(ge,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:s?e.jsx(an,{onSuccess:g,onCancel:()=>i(!1)}):e.jsx(Ts,{organizationId:u||n,onSuccess:l,onCancel:r,onCreateOrganization:p})})})})})})},Kx=d.div`
3090
+ `,Ts=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var I;const[s,a]=i.useState(""),[p,f]=i.useState(""),[c,h]=i.useState(),[l,u]=i.useState(null),[g,v]=i.useState(!1),[x,w]=i.useState(!1),[$,S]=i.useState(t),k=i.useRef(null),P=i.useRef(null),{toast:E}=He(),{createWorkspace:z}=Pt(),{organizationMemberships:y}=Ct(),m=(I=y==null?void 0:y.find(M=>M.organization.id===$))==null?void 0:I.organization,b=M=>{if(M.target.files&&M.target.files[0]){const F=M.target.files[0];if(F.size>2*1024*1024){E("File size cannot exceed 2MB","error");return}if(!F.type.startsWith("image/")){E("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),h(F),u(URL.createObjectURL(F))}},_=()=>{var M;(M=k.current)==null||M.click()},j=M=>M.split(" ").map(F=>F[0]).join("").toUpperCase().slice(0,2)||"W",T=M=>M.trim().replace(/[<>\"'&]/g,""),R=M=>M.length>=2&&M.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(M),C=async()=>{const M=T(s),F=T(p);if(!M||!$){E("Please enter a workspace name","error");return}if(!R(M)){E("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(F.length>500){E("Description must be less than 500 characters","error");return}v(!0);try{const L=await z($,M,c,F);r==null||r(L)}catch(L){const B=L.message||"Failed to create workspace. Please try again.";E(B,"error")}finally{v(!1)}};return i.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]),i.useEffect(()=>{const M=F=>{P.current&&!P.current.contains(F.target)&&w(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]),e.jsx(ge,{children:e.jsxs(Sx,{children:[e.jsxs(zx,{children:[e.jsxs(Ml,{hasImage:!!l,onClick:_,children:[l?e.jsx(Ex,{src:l,alt:"Workspace logo"}):e.jsx(Ix,{children:j(s||"W")}),e.jsx(Wx,{children:e.jsx(Vx,{children:"Upload Logo"})})]}),e.jsx(Ux,{type:"file",ref:k,onChange:b,accept:"image/png, image/jpeg, image/gif",disabled:g}),e.jsx(Px,{children:"Create new workspace"}),e.jsx(Rx,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs($x,{children:[e.jsxs(Tx,{children:[e.jsx(Mx,{children:"Choose your workspace name"}),e.jsx(Ox,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(Ax,{children:[e.jsxs(Un,{children:[e.jsx(Wn,{children:"Organization"}),e.jsxs(Gx,{ref:P,children:[e.jsxs(Hx,{type:"button",onClick:()=>w(!x),disabled:g,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(oi,{children:m!=null&&m.image_url?e.jsx(ni,{src:m.image_url,alt:m.name}):j((m==null?void 0:m.name)||"O").charAt(0)}),e.jsx("span",{children:(m==null?void 0:m.name)||"Select organization"})]}),e.jsx(or,{size:16,style:{color:"var(--color-secondary-text)"}})]}),x&&e.jsxs(qx,{children:[y==null?void 0:y.map(M=>e.jsxs(Ol,{onClick:()=>{S(M.organization.id),w(!1)},children:[e.jsx(oi,{children:M.organization.image_url?e.jsx(ni,{src:M.organization.image_url,alt:M.organization.name}):j(M.organization.name).charAt(0)}),e.jsx("span",{children:M.organization.name})]},M.organization.id)),e.jsxs(Yx,{onClick:()=>{w(!1),n==null||n()},children:[e.jsx(Zx,{children:e.jsx(Ke,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Workspace name"}),e.jsx(Lx,{type:"text",value:s,onChange:M=>a(M.target.value),placeholder:"Workspace Name",disabled:g})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Description (optional)"}),e.jsx(Dx,{value:p,onChange:M=>f(M.target.value),placeholder:"What is this workspace for?",disabled:g})]})]}),e.jsxs(Nx,{children:[o?e.jsxs(Fx,{onClick:o,disabled:g,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Bx,{onClick:C,disabled:g||!s.trim(),children:g?"Creating...":"Create"})]})]})]})})},Al=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[s,a]=i.useState(!1),[p,f]=i.useState(n),{refetch:c,organizationMemberships:h}=Ct(),l=()=>{o==null||o(),r==null||r()},u=()=>{a(!0)},g=async()=>{await c(),setTimeout(()=>{if(h&&h.length>0){const v=h[h.length-1];f(v.organization.id)}a(!1)},500)};return e.jsx(ge,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:s?e.jsx(an,{onSuccess:g,onCancel:()=>a(!1)}):e.jsx(Ts,{organizationId:p||n,onSuccess:l,onCancel:r,onCreateOrganization:u})})})})})})},Kx=d.div`
3091
3091
  position: fixed;
3092
3092
  width: 360px;
3093
3093
  max-width: calc(100vw - 48px);
@@ -3136,7 +3136,7 @@ cursor: pointer;
3136
3136
  color: var(--color-foreground);
3137
3137
  background: var(--color-input-background);
3138
3138
  }
3139
- `,r0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:s})=>{const i=a.useRef(null),[u,f]=a.useState(""),[c,h]=a.useState(null),[l,p]=a.useState(!1),[g,x]=a.useState(!1),[m,b]=a.useState({top:0,left:0}),{toast:$}=He(),z=o.map(k=>({value:k.id,label:k.name}));a.useEffect(()=>{x(!0);const k=setTimeout(()=>{if(!i.current||!(s!=null&&s.current))return;const P=s.current;if(P){const I=P.getBoundingClientRect(),S=360,T=250,E=8;let j=0,R=0;const M=window.innerHeight-I.bottom,F=I.top;M>=T+E?(j=I.bottom+E,R=I.right-S,R<E&&(R=I.left,R+S>window.innerWidth-E&&(R=(window.innerWidth-S)/2))):F>=T+E?(j=I.top-T-E,R=I.right-S,R<E&&(R=I.left,R+S>window.innerWidth-E&&(R=(window.innerWidth-S)/2))):(j=I.bottom+E,R=I.right-S,R<E&&(R=I.left)),b({top:j,left:R})}},10),C=P=>{i.current&&!i.current.contains(P.target)&&(t==null||t())},_=P=>{P.key==="Escape"&&(t==null||t())},v=setTimeout(()=>{document.addEventListener("mousedown",C),document.addEventListener("keydown",_)},100);return()=>{clearTimeout(k),clearTimeout(v),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",_)}},[t,s]);const w=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),y=async()=>{const k=u.trim().toLowerCase();if(!(!k||!c)){if(!w(k)){$("Please enter a valid email address","error");return}if(k.length>320){$("Email address is too long","error");return}p(!0);try{await n(k,c.id),r==null||r()}catch(C){const _=C.message||"Failed to send invitation. Please try again.";$(_,"error")}finally{p(!1)}}};return g?e.jsxs(Kx,{ref:i,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(Qx,{children:[e.jsx(Xx,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(t0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Jx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ae,{children:"Email Address"}),e.jsx(ce,{type:"email",placeholder:"colleague@company.com",value:u,onChange:k=>f(k.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Role"}),e.jsx(Is,{options:z,value:c==null?void 0:c.id,onChange:k=>h(o.find(C=>C.id===k)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(e0,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:y,disabled:!u||!c||l,style:{width:"auto"},children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},o0=d.div`
3139
+ `,r0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:s})=>{const a=i.useRef(null),[p,f]=i.useState(""),[c,h]=i.useState(null),[l,u]=i.useState(!1),[g,v]=i.useState(!1),[x,w]=i.useState({top:0,left:0}),{toast:$}=He(),S=o.map(E=>({value:E.id,label:E.name}));i.useEffect(()=>{v(!0);const E=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const b=s.current;if(b){const _=b.getBoundingClientRect(),j=360,T=250,R=8;let C=0,I=0;const M=window.innerHeight-_.bottom,F=_.top;M>=T+R?(C=_.bottom+R,I=_.right-j,I<R&&(I=_.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):F>=T+R?(C=_.top-T-R,I=_.right-j,I<R&&(I=_.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(C=_.bottom+R,I=_.right-j,I<R&&(I=_.left)),w({top:C,left:I})}},10),z=b=>{a.current&&!a.current.contains(b.target)&&(t==null||t())},y=b=>{b.key==="Escape"&&(t==null||t())},m=setTimeout(()=>{document.addEventListener("mousedown",z),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(E),clearTimeout(m),document.removeEventListener("mousedown",z),document.removeEventListener("keydown",y)}},[t,s]);const k=E=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E),P=async()=>{const E=p.trim().toLowerCase();if(!(!E||!c)){if(!k(E)){$("Please enter a valid email address","error");return}if(E.length>320){$("Email address is too long","error");return}u(!0);try{await n(E,c.id),r==null||r()}catch(z){const y=z.message||"Failed to send invitation. Please try again.";$(y,"error")}finally{u(!1)}}};return g?e.jsxs(Kx,{ref:a,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(Qx,{children:[e.jsx(Xx,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(t0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Jx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Email Address"}),e.jsx(le,{type:"email",placeholder:"colleague@company.com",value:p,onChange:E=>f(E.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Role"}),e.jsx(Is,{options:S,value:c==null?void 0:c.id,onChange:E=>h(o.find(z=>z.id===E)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(e0,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:P,disabled:!p||!c||l,style:{width:"auto"},children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},o0=d.div`
3140
3140
  position: fixed;
3141
3141
  width: 360px;
3142
3142
  max-width: calc(100vw - 48px);
@@ -3160,9 +3160,9 @@ cursor: pointer;
3160
3160
  font-size: var(--font-xs);
3161
3161
  font-weight: 400;
3162
3162
  color: var(--color-foreground);
3163
- `,i0=d.div`
3164
- padding: var(--space-md);
3165
3163
  `,a0=d.div`
3164
+ padding: var(--space-md);
3165
+ `,i0=d.div`
3166
3166
  display: flex;
3167
3167
  gap: var(--space-xs);
3168
3168
  justify-content: flex-end;
@@ -3185,12 +3185,12 @@ cursor: pointer;
3185
3185
  color: var(--color-foreground);
3186
3186
  background: var(--color-input-background);
3187
3187
  }
3188
- `,sa=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var k;const s=a.useRef(null),[i,u]=a.useState((o==null?void 0:o.name)||""),[f,c]=a.useState((o==null?void 0:o.permissions)||[]),[h,l]=a.useState(!1),{deployment:p}=ve(),[g,x]=a.useState(!1),[m,b]=a.useState({top:0,left:0}),{toast:$}=He(),z=!!o,w=(((k=p==null?void 0:p.b2b_settings)==null?void 0:k.workspace_permissions)||[]).map(C=>({value:C,label:C}));a.useEffect(()=>{x(!0);const C=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const I=n.current;if(I){const S=I.getBoundingClientRect(),T=360,E=250,j=8;let R=0,M=0;const F=window.innerHeight-S.bottom,A=S.top;F>=E+j?(R=S.bottom+j,M=S.right-T,M<j&&(M=S.left,M+T>window.innerWidth-j&&(M=(window.innerWidth-T)/2))):A>=E+j?(R=S.top-E-j,M=S.right-T,M<j&&(M=S.left,M+T>window.innerWidth-j&&(M=(window.innerWidth-T)/2))):(R=S.bottom+j,M=S.right-T,M<j&&(M=S.left)),b({top:R,left:M})}},10),_=I=>{s.current&&!s.current.contains(I.target)&&(t==null||t())},v=I=>{I.key==="Escape"&&(t==null||t())},P=setTimeout(()=>{document.addEventListener("mousedown",_),document.addEventListener("keydown",v)},100);return()=>{clearTimeout(C),clearTimeout(P),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",v)}},[t,n]);const y=async()=>{if(i.trim()){l(!0);try{const C={id:o==null?void 0:o.id,name:i.trim(),permissions:f};r==null||r(C)}catch(C){const _=C.message||"Failed to save role. Please try again.";$(_,"error")}finally{l(!1)}}};return g?e.jsxs(o0,{ref:s,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:C=>C.stopPropagation(),children:[e.jsxs(n0,{children:[e.jsx(s0,{children:z?"Edit Role":"Add Role"}),e.jsx(c0,{onClick:t,children:e.jsx(et,{size:16})})]}),e.jsx(i0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ae,{children:"Role Name"}),e.jsx(ce,{type:"text",value:i,onChange:C=>u(C.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{children:"Permissions"}),e.jsx(bl,{options:w,value:f,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(a0,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:y,disabled:!i.trim()||h,style:{width:"auto"},children:h?"Saving...":z?"Update":"Create"})]})]}):null},l0=d.div`
3188
+ `,si=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var E;const s=i.useRef(null),[a,p]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]),[h,l]=i.useState(!1),{deployment:u}=ve(),[g,v]=i.useState(!1),[x,w]=i.useState({top:0,left:0}),{toast:$}=He(),S=!!o,k=(((E=u==null?void 0:u.b2b_settings)==null?void 0:E.workspace_permissions)||[]).map(z=>({value:z,label:z}));i.useEffect(()=>{v(!0);const z=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const _=n.current;if(_){const j=_.getBoundingClientRect(),T=360,R=250,C=8;let I=0,M=0;const F=window.innerHeight-j.bottom,L=j.top;F>=R+C?(I=j.bottom+C,M=j.right-T,M<C&&(M=j.left,M+T>window.innerWidth-C&&(M=(window.innerWidth-T)/2))):L>=R+C?(I=j.top-R-C,M=j.right-T,M<C&&(M=j.left,M+T>window.innerWidth-C&&(M=(window.innerWidth-T)/2))):(I=j.bottom+C,M=j.right-T,M<C&&(M=j.left)),w({top:I,left:M})}},10),y=_=>{s.current&&!s.current.contains(_.target)&&(t==null||t())},m=_=>{_.key==="Escape"&&(t==null||t())},b=setTimeout(()=>{document.addEventListener("mousedown",y),document.addEventListener("keydown",m)},100);return()=>{clearTimeout(z),clearTimeout(b),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",m)}},[t,n]);const P=async()=>{if(a.trim()){l(!0);try{const z={id:o==null?void 0:o.id,name:a.trim(),permissions:f};r==null||r(z)}catch(z){const y=z.message||"Failed to save role. Please try again.";$(y,"error")}finally{l(!1)}}};return g?e.jsxs(o0,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),children:[e.jsxs(n0,{children:[e.jsx(s0,{children:S?"Edit Role":"Add Role"}),e.jsx(c0,{onClick:t,children:e.jsx(et,{size:16})})]}),e.jsx(a0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Role Name"}),e.jsx(le,{type:"text",value:a,onChange:z=>p(z.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Permissions"}),e.jsx(bl,{options:k,value:f,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(i0,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:P,disabled:!a.trim()||h,style:{width:"auto"},children:h?"Saving...":S?"Update":"Create"})]})]}):null},l0=d.div`
3189
3189
  * {
3190
3190
  box-sizing: border-box;
3191
3191
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3192
3192
  }
3193
- `,ia=d.div`
3193
+ `,ai=d.div`
3194
3194
  width: 100%;
3195
3195
  height: 600px;
3196
3196
  background: var(--color-background);
@@ -3321,11 +3321,11 @@ cursor: pointer;
3321
3321
  opacity: 0.5;
3322
3322
  cursor: not-allowed;
3323
3323
  }
3324
- `,f0=()=>{const{activeWorkspace:t,loading:r,getRoles:o}=Rt(),{workspaces:n}=St(),{client:s}=Fe(),{toast:i}=He(),u=n==null?void 0:n.find(T=>T.id===(t==null?void 0:t.id)),[f,c]=a.useState(!0),[h,l]=a.useState(!0),[p,g]=a.useState(""),[x,m]=a.useState([]),[b,$]=a.useState([]),[z,w]=a.useState(!1),y=a.useRef(null),k=a.useCallback(async()=>{if(!t||!u)return[];try{return(await G(await s(`/organizations/${u.organization.id}/invitations`,{method:"GET"}))).data.filter(j=>String(j.workspace_id)===String(t.id))}catch{return[]}},[s,t,u]),C=a.useCallback(async(T,E)=>{if(!t||!u)return;const j=new FormData;return j.append("email",T),j.append("workspace_id",t.id),j.append("workspace_role_id",E),(await G(await s(`/organizations/${u.organization.id}/invitations`,{method:"POST",body:j}))).data},[s,t,u]),_=a.useCallback(async T=>!t||!u?void 0:(await G(await s(`/organizations/${u.organization.id}/invitations/${T}/discard`,{method:"POST"}))).data,[s,t,u]);a.useEffect(()=>{if(!t)return;(async()=>{c(!0),l(!0);try{const[E,j]=await Promise.all([o(),k()]);$(E),m(j)}catch{}finally{c(!1),l(!1)}})()},[t==null?void 0:t.id]);const v=async T=>{try{await _(T.id);const E=await k();m(E)}catch{}},P=async T=>{var E;try{await _(T.id),await C(T.email,T.workspace_role_id||((E=T.initial_workspace_role)==null?void 0:E.id)||T.role_id);const j=await k();m(j),i("Invitation resent successfully","info")}catch{}},I=async()=>{w(!1);const T=await k();m(T),i("Invitation sent successfully","info")},S=a.useMemo(()=>p?x.filter(T=>(T.email||"").toLowerCase().includes(p.toLowerCase())):x,[x,p]);return r||f||h?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{children:[e.jsx(zt,{value:p,onChange:g,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(Q,{ref:y,onClick:()=>w(!z),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),z&&e.jsx(r0,{onClose:()=>w(!1),onSuccess:I,roles:b,createInvitation:C,triggerRef:y})]})]}),e.jsx("div",{children:S.length===0?e.jsx(at,{title:p?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:S.map(T=>{var E,j;return e.jsxs(Ne,{children:[e.jsx(Me,{children:T.email}),e.jsx(Me,{children:((E=T.initial_workspace_role)==null?void 0:E.name)||((j=T.initial_organization_role)==null?void 0:j.name)||"No role"}),e.jsx(Me,{children:new Date(T.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsx(Ll,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>P(T),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx($s,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>v(T),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},T.id)})})]})})]})},g0=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:s,addMemberRole:i,removeMemberRole:u}=Rt(),{session:f}=Ue(),{toast:c}=He(),[h,l]=a.useState(""),{data:p=[],isLoading:g,mutate:x}=Be(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:m=[],isLoading:b}=Be(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),$=m,z=a.useMemo(()=>h?p.filter(_=>{var E;const v=_.public_user_data;if(!v)return!1;const P=v.first_name||"",I=v.last_name||"",S=((E=v.primary_email_address)==null?void 0:E.email)||"";return`${P} ${I}`.trim().toLowerCase().includes(h.toLowerCase())||S.toLowerCase().includes(h.toLowerCase())}):p,[p,h]),w=async _=>{try{await s(_),c("Member removed successfully","info"),x()}catch{c("Failed to remove member","error")}},y=async(_,v,P)=>{try{P?(await u(_,v),c("Role removed successfully","info")):(await i(_,v),c("Role added successfully","info")),x()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},k=(_="",v="")=>`${_[0]||""}${v[0]||""}`.toUpperCase(),C=(_,v)=>{var P;return((P=_.roles)==null?void 0:P.some(I=>I.id===v))||!1};return r||g||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Ms,{children:e.jsx(zt,{value:h,onChange:l,placeholder:"Search members..."})}),z.length===0?e.jsx(at,{title:h?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Role"})]})}),e.jsx(gt,{children:z.map(_=>{var S,T;const v=_.public_user_data,P=_.roles||[],I=(v==null?void 0:v.id)===((S=f==null?void 0:f.active_signin)==null?void 0:S.user_id);return e.jsxs(Ne,{children:[e.jsx(El,{children:e.jsxs("div",{children:[e.jsx(h0,{children:v&&v.profile_picture_url?e.jsx("img",{src:v.profile_picture_url,alt:`${v.first_name||""} ${v.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):k(v==null?void 0:v.first_name,v==null?void 0:v.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var j;if(!v)return"Unknown User";const E=`${v.first_name||""} ${v.last_name||""}`.trim();return E||((j=v.primary_email_address)==null?void 0:j.email)||"Unknown User"})()}),I&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(T=v==null?void 0:v.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Me,{children:new Date(_.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsxs(Q,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:P.length>0?P[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[$.map(E=>{const j=C(_,E.id);return e.jsx(Te,{onClick:()=>y(_.id,E.id,j),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:E.name}),j&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},E.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>w(_.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},_.id)})})]})]})},m0=()=>{var X,ee;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Rt(),{deleteWorkspace:n}=St(),{deployment:s}=ve(),{toast:i}=He(),[u,f]=a.useState((t==null?void 0:t.name)||""),[c,h]=a.useState((t==null?void 0:t.description)||""),[l,p]=a.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[g,x]=a.useState(null),[m,b]=a.useState((t==null?void 0:t.image_url)||null),[$,z]=a.useState(!1),[w,y]=a.useState(!1),[k,C]=a.useState(""),[_,v]=a.useState(!1),[P,I]=a.useState(!1),S=a.useRef(null),T=a.useRef(null);if(a.useEffect(()=>{var V;t&&(f(t.name||""),h(t.description||""),b(t.image_url||null),p({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((V=t.whitelisted_ips)==null?void 0:V.join(`
3325
- `))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const E=V=>{var q;if((q=V.target.files)!=null&&q[0]){const te=V.target.files[0];x(te),b(URL.createObjectURL(te)),setTimeout(()=>R(),100)}},j=()=>{S.current&&S.current.click()},R=a.useCallback(async()=>{if(!(!t||w))try{y(!0);const V={};g&&(V.image=g,x(null)),u!==t.name&&(V.name=u),c!==t.description&&(V.description=c),l.mfa_required!==t.enforce_2fa&&(V.enforce_2fa=l.mfa_required),l.ip_restrictions!==t.enable_ip_restriction&&(V.enable_ip_restriction=l.ip_restrictions);const q=(t.whitelisted_ips||[]).join(`
3324
+ `,f0=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,createInvitation:s,discardInvitation:a,resendInvitation:p}=Rt(),{toast:f}=He(),[c,h]=i.useState(!0),[l,u]=i.useState(!0),[g,v]=i.useState(""),[x,w]=i.useState([]),[$,S]=i.useState([]),[k,P]=i.useState(!1),E=i.useRef(null);i.useEffect(()=>{if(!t)return;(async()=>{h(!0),u(!0);try{const[j,T]=await Promise.all([o(),n()]);S(j),w(T)}catch{}finally{h(!1),u(!1)}})()},[t==null?void 0:t.id]);const z=async _=>{try{await a(_.id);const j=await n();w(j)}catch{}},y=async _=>{try{await p(_.id);const j=await n();w(j),f("Invitation resent successfully","info")}catch{}},m=async()=>{P(!1);const _=await n();w(_),f("Invitation sent successfully","info")},b=i.useMemo(()=>g?x.filter(_=>(_.email||"").toLowerCase().includes(g.toLowerCase())):x,[x,g]);return r||c||l?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{children:[e.jsx(St,{value:g,onChange:v,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(Q,{ref:E,onClick:()=>P(!k),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),k&&e.jsx(r0,{onClose:()=>P(!1),onSuccess:m,roles:$,createInvitation:s,triggerRef:E})]})]}),e.jsx("div",{children:b.length===0?e.jsx(it,{title:g?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:b.map(_=>{var j,T;return e.jsxs(Ne,{children:[e.jsx(Me,{children:_.email}),e.jsx(Me,{children:((j=_.initial_workspace_role)==null?void 0:j.name)||((T=_.initial_organization_role)==null?void 0:T.name)||"No role"}),e.jsx(Me,{children:new Date(_.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsx(Ll,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>y(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx($s,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>z(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},_.id)})})]})})]})},g0=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:s,addMemberRole:a,removeMemberRole:p}=Rt(),{session:f}=Ue(),{toast:c}=He(),[h,l]=i.useState(""),{data:u=[],isLoading:g,mutate:v}=Fe(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:x=[],isLoading:w}=Fe(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),$=x,S=i.useMemo(()=>h?u.filter(y=>{var R;const m=y.public_user_data;if(!m)return!1;const b=m.first_name||"",_=m.last_name||"",j=((R=m.primary_email_address)==null?void 0:R.email)||"";return`${b} ${_}`.trim().toLowerCase().includes(h.toLowerCase())||j.toLowerCase().includes(h.toLowerCase())}):u,[u,h]),k=async y=>{try{await s(y),c("Member removed successfully","info"),v()}catch{c("Failed to remove member","error")}},P=async(y,m,b)=>{try{b?(await p(y,m),c("Role removed successfully","info")):(await a(y,m),c("Role added successfully","info")),v()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},E=(y="",m="")=>`${y[0]||""}${m[0]||""}`.toUpperCase(),z=(y,m)=>{var b;return((b=y.roles)==null?void 0:b.some(_=>_.id===m))||!1};return r||g||w?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Ms,{children:e.jsx(St,{value:h,onChange:l,placeholder:"Search members..."})}),S.length===0?e.jsx(it,{title:h?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Role"})]})}),e.jsx(gt,{children:S.map(y=>{var j,T;const m=y.public_user_data,b=y.roles||[],_=(m==null?void 0:m.id)===((j=f==null?void 0:f.active_signin)==null?void 0:j.user_id);return e.jsxs(Ne,{children:[e.jsx(El,{children:e.jsxs("div",{children:[e.jsx(h0,{children:m&&m.profile_picture_url?e.jsx("img",{src:m.profile_picture_url,alt:`${m.first_name||""} ${m.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):E(m==null?void 0:m.first_name,m==null?void 0:m.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var C;if(!m)return"Unknown User";const R=`${m.first_name||""} ${m.last_name||""}`.trim();return R||((C=m.primary_email_address)==null?void 0:C.email)||"Unknown User"})()}),_&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(T=m==null?void 0:m.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Me,{children:new Date(y.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(Q,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:b.length>0?b[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[$.map(R=>{const C=z(y,R.id);return e.jsx(Te,{onClick:()=>P(y.id,R.id,C),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:R.name}),C&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},R.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>k(y.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},y.id)})})]})]})},m0=()=>{var X,te;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Rt(),{deleteWorkspace:n}=Pt(),{deployment:s}=ve(),{toast:a}=He(),[p,f]=i.useState((t==null?void 0:t.name)||""),[c,h]=i.useState((t==null?void 0:t.description)||""),[l,u]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[g,v]=i.useState(null),[x,w]=i.useState((t==null?void 0:t.image_url)||null),[$,S]=i.useState(!1),[k,P]=i.useState(!1),[E,z]=i.useState(""),[y,m]=i.useState(!1),[b,_]=i.useState(!1),j=i.useRef(null),T=i.useRef(null);if(i.useEffect(()=>{var V;t&&(f(t.name||""),h(t.description||""),w(t.image_url||null),u({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((V=t.whitelisted_ips)==null?void 0:V.join(`
3325
+ `))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const R=V=>{var q;if((q=V.target.files)!=null&&q[0]){const re=V.target.files[0];v(re),w(URL.createObjectURL(re)),setTimeout(()=>I(),100)}},C=()=>{j.current&&j.current.click()},I=i.useCallback(async()=>{if(!(!t||k))try{P(!0);const V={};g&&(V.image=g,v(null)),p!==t.name&&(V.name=p),c!==t.description&&(V.description=c),l.mfa_required!==t.enforce_2fa&&(V.enforce_2fa=l.mfa_required),l.ip_restrictions!==t.enable_ip_restriction&&(V.enable_ip_restriction=l.ip_restrictions);const q=(t.whitelisted_ips||[]).join(`
3326
3326
  `);l.allowed_ips!==q&&(V.whitelisted_ips=l.allowed_ips.split(`
3327
- `).map(te=>te.trim()).filter(te=>te!=="")),Object.keys(V).length>0&&(await o(V),z(!0),setTimeout(()=>z(!1),3e3))}catch{i("Failed to auto-save workspace","error")}finally{y(!1)}},[t,o,u,c,g,l,w]),M=a.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{R()},1e3)},[R]),F=V=>{f(V.target.value),M()},A=V=>{h(V.target.value),M()},B=()=>{T.current&&clearTimeout(T.current),R()},O=()=>{T.current&&clearTimeout(T.current),R()},L=async()=>{if(!(!t||k!==t.name))try{v(!0),await n(t),i("Workspace deleted successfully","info")}catch(V){i(V.message||"Failed to delete workspace","error")}finally{v(!1),C(""),I(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:m?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:j,onMouseEnter:V=>{V.currentTarget.style.borderColor="var(--color-primary)",V.currentTarget.style.transform="scale(1.02)"},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--color-border)",V.currentTarget.style.transform="scale(1)"},children:[m?e.jsx("img",{src:m,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:S,style:{display:"none"},accept:"image/*",onChange:E})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var V;return(V=S.current)==null?void 0:V.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Ur,{size:14}),m?"Change":"Upload"]}),e.jsxs(Q,{onClick:()=>{b(null),x(null),S.current&&(S.current.value=""),setTimeout(()=>R(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(nn,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"name",children:"Workspace Name"}),e.jsx(ce,{id:"name",type:"text",value:u,onChange:F,onBlur:B,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"description",children:"Description"}),e.jsx(ce,{id:"description",as:"textarea",value:c,onChange:A,onBlur:O,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]}),((X=s==null?void 0:s.b2b_settings)==null?void 0:X.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ae,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(Cr,{checked:l.mfa_required,onChange:()=>{p(V=>({...V,mfa_required:!V.mfa_required})),setTimeout(()=>R(),100)}})]}),((ee=s==null?void 0:s.b2b_settings)==null?void 0:ee.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ae,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(Cr,{checked:l.ip_restrictions,onChange:()=>{p(V=>({...V,ip_restrictions:!V.ip_restrictions})),setTimeout(()=>R(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),l.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(ce,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:V=>p(q=>({...q,allowed_ips:V.target.value})),onBlur:R,placeholder:`192.168.1.1
3328
- 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:P?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{P?(I(!1),C("")):I(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:P?"Cancel":"Delete"})]}),P&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(ce,{id:"confirm_workspace_name",type:"text",value:k,onChange:V=>C(V.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Q,{onClick:L,disabled:k!==(t==null?void 0:t.name)||_,style:{background:k===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:k===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:k===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:k===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:_?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]}),$&&e.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"var(--color-success-background)",color:"var(--color-success)",padding:"var(--space-sm) var(--space-lg)",borderRadius:"var(--radius-lg)",boxShadow:"0 4px 12px var(--color-shadow)",display:"flex",alignItems:"center",gap:"var(--space-xs)",fontSize:"var(--font-xs)",fontWeight:500,zIndex:1e3,animation:"slideUp 0.3s ease-out"},children:"✓ Changes saved automatically"}),e.jsx("style",{children:`
3327
+ `).map(re=>re.trim()).filter(re=>re!=="")),Object.keys(V).length>0&&(await o(V),S(!0),setTimeout(()=>S(!1),3e3))}catch{a("Failed to auto-save workspace","error")}finally{P(!1)}},[t,o,p,c,g,l,k]),M=i.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{I()},1e3)},[I]),F=V=>{f(V.target.value),M()},L=V=>{h(V.target.value),M()},B=()=>{T.current&&clearTimeout(T.current),I()},O=()=>{T.current&&clearTimeout(T.current),I()},A=async()=>{if(!(!t||E!==t.name))try{m(!0),await n(t),a("Workspace deleted successfully","info")}catch(V){a(V.message||"Failed to delete workspace","error")}finally{m(!1),z(""),_(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:C,onMouseEnter:V=>{V.currentTarget.style.borderColor="var(--color-primary)",V.currentTarget.style.transform="scale(1.02)"},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--color-border)",V.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:j,style:{display:"none"},accept:"image/*",onChange:R})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var V;return(V=j.current)==null?void 0:V.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Ur,{size:14}),x?"Change":"Upload"]}),e.jsxs(Q,{onClick:()=>{w(null),v(null),j.current&&(j.current.value=""),setTimeout(()=>I(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(nn,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"name",children:"Workspace Name"}),e.jsx(le,{id:"name",type:"text",value:p,onChange:F,onBlur:B,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"description",children:"Description"}),e.jsx(le,{id:"description",as:"textarea",value:c,onChange:L,onBlur:O,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]}),((X=s==null?void 0:s.b2b_settings)==null?void 0:X.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(Cr,{checked:l.mfa_required,onChange:()=>{u(V=>({...V,mfa_required:!V.mfa_required})),setTimeout(()=>I(),100)}})]}),((te=s==null?void 0:s.b2b_settings)==null?void 0:te.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(Cr,{checked:l.ip_restrictions,onChange:()=>{u(V=>({...V,ip_restrictions:!V.ip_restrictions})),setTimeout(()=>I(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),l.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(le,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:V=>u(q=>({...q,allowed_ips:V.target.value})),onBlur:I,placeholder:`192.168.1.1
3328
+ 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:b?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{b?(_(!1),z("")):_(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:b?"Cancel":"Delete"})]}),b&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(le,{id:"confirm_workspace_name",type:"text",value:E,onChange:V=>z(V.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Q,{onClick:A,disabled:E!==(t==null?void 0:t.name)||y,style:{background:E===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:E===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:E===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:E===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:y?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]}),$&&e.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"var(--color-success-background)",color:"var(--color-success)",padding:"var(--space-sm) var(--space-lg)",borderRadius:"var(--radius-lg)",boxShadow:"0 4px 12px var(--color-shadow)",display:"flex",alignItems:"center",gap:"var(--space-xs)",fontSize:"var(--font-xs)",fontWeight:500,zIndex:1e3,animation:"slideUp 0.3s ease-out"},children:"✓ Changes saved automatically"}),e.jsx("style",{children:`
3329
3329
  @keyframes slideUp {
3330
3330
  from {
3331
3331
  opacity: 0;
@@ -3336,7 +3336,7 @@ cursor: pointer;
3336
3336
  transform: translateX(-50%) translateY(0);
3337
3337
  }
3338
3338
  }
3339
- `})]})},x0=()=>{var v;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:s}=Rt(),{toast:i}=He(),{deployment:u}=ve(),[f,c]=a.useState(""),[h,l]=a.useState({isOpen:!1}),[p,g]=a.useState(null),[x,m]=a.useState(null),b=a.useRef(null),$=a.useRef(new Map),{data:z=[],isLoading:w,mutate:y}=Be(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),k=a.useMemo(()=>f?z.filter(P=>P.name.toLowerCase().includes(f.toLowerCase())):z,[z,f]),C=async P=>{try{await n(P.name,P.permissions||[]),i("Role created successfully","info"),l({isOpen:!1}),y()}catch{i("Failed to save role","error"),i("Failed to create role","error")}},_=async P=>{try{await s(P),i("Role deleted successfully","info"),m(null),y()}catch{i("Failed to delete role","error"),i("Failed to delete role","error")}};return r||w?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{children:[e.jsx(zt,{placeholder:"Search roles",onChange:c,value:f}),e.jsxs("div",{style:{position:"relative"},children:[((v=u==null?void 0:u.b2b_settings)==null?void 0:v.custom_workspace_role_enabled)&&e.jsx(Q,{ref:b,onClick:()=>l({isOpen:!0,triggerElement:b.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),h.isOpen&&!h.role&&e.jsx(sa,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:C})]})]}),k.length===0?e.jsx(at,{title:f?"No roles match your search":"No roles available",description:f?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:k.map(P=>{var I;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:P.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:P.permissions&&P.permissions.length>0?P.permissions.join(", "):""}),e.jsx(mt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:p===P.id,openChange:S=>g(S?P.id:null),children:[e.jsx(it,{children:e.jsx(Ll,{ref:S=>{S&&$.current.set(P.id,S)},disabled:!P.workspace_id,"data-role-dropdown-trigger":P.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{g(null);const S=$.current.get(P.id);l({isOpen:!0,role:P,triggerElement:S||null})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{g(null),m(P.id)},children:"Remove Role"})]})]}),x===P.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>_(P),onCancel:()=>m(null)}),h.isOpen&&((I=h.role)==null?void 0:I.id)===P.id&&e.jsx(sa,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>{l({isOpen:!1}),g(null)},onSuccess:C})]})})]},P.id)})})]})})]})},Dl=()=>{const{activeWorkspace:t,loading:r}=Rt(),[o,n]=a.useState("general"),[s,i]=a.useState(null),[u,f]=a.useState("info"),c=a.useCallback((h,l="info")=>{i(h),f(l),setTimeout(()=>i(null),3e3)},[]);return r?e.jsx(ia,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):t?e.jsx(Ps.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(l0,{children:e.jsxs(ia,{children:[e.jsx(d0,{children:e.jsxs(u0,{children:[e.jsx(xo,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(vo,{children:[e.jsx(er,{size:16}),"General"]})}),e.jsx(xo,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(vo,{children:[e.jsx(Uo,{size:16}),"Members"]})}),e.jsx(xo,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(vo,{children:[e.jsx($s,{size:16}),"Invitations"]})}),e.jsx(xo,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(vo,{children:[e.jsx(Qe,{size:16}),"Roles"]})})]})}),e.jsxs(p0,{children:[o==="general"&&e.jsx(m0,{}),o==="members"&&e.jsx(g0,{}),o==="invitations"&&e.jsx(f0,{}),o==="roles"&&e.jsx(x0,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):null},Nl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:i,customContent:u,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),u||f||e.jsx(Dl,{}),i&&e.jsx(ke.Footer,{children:i})]})})}),Fl=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:s=8})=>{const[i,u]=a.useState();return a.useEffect(()=>{if(!r||!t.current){u(void 0);return}const f=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),h=window.innerWidth,l=window.innerHeight,p=h-c.left,g=c.right,x=l-c.bottom,m=c.top;let b={};p>=o?b.left=c.left:g>=o?b.left=c.right-o:b.left=Math.max(s,Math.min(h-o-s,c.left)),x>=150?(b.top=c.bottom+s,b.maxHeight=Math.min(n,x-s*2)):m>=150?(b.bottom=l-c.top+s,b.maxHeight=Math.min(n,m-s*2)):(b.top=c.bottom+s,b.maxHeight=Math.max(100,x-s*2)),u(b)};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[r,o,n,s]),i},Bl=["organization:admin"],Ul=["organization:admin","organization:manage"],Wl=["workspace:admin"],Vl=["workspace:admin","workspace:manage"];function Os(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function Gl(t){return Os(t,Ul)}function v0(t){return Os(t,Bl)}function As(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function xs(t){return As(t,Vl)}function b0(t){return As(t,Wl)}const aa=d.div`
3339
+ `})]})},x0=()=>{var m;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:s}=Rt(),{toast:a}=He(),{deployment:p}=ve(),[f,c]=i.useState(""),[h,l]=i.useState({isOpen:!1}),[u,g]=i.useState(null),[v,x]=i.useState(null),w=i.useRef(null),$=i.useRef(new Map),{data:S=[],isLoading:k,mutate:P}=Fe(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),E=i.useMemo(()=>f?S.filter(b=>b.name.toLowerCase().includes(f.toLowerCase())):S,[S,f]),z=async b=>{try{await n(b.name,b.permissions||[]),a("Role created successfully","info"),l({isOpen:!1}),P()}catch{a("Failed to save role","error"),a("Failed to create role","error")}},y=async b=>{try{await s(b),a("Role deleted successfully","info"),x(null),P()}catch{a("Failed to delete role","error"),a("Failed to delete role","error")}};return r||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{children:[e.jsx(St,{placeholder:"Search roles",onChange:c,value:f}),e.jsxs("div",{style:{position:"relative"},children:[((m=p==null?void 0:p.b2b_settings)==null?void 0:m.custom_workspace_role_enabled)&&e.jsx(Q,{ref:w,onClick:()=>l({isOpen:!0,triggerElement:w.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),h.isOpen&&!h.role&&e.jsx(si,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:z})]})]}),E.length===0?e.jsx(it,{title:f?"No roles match your search":"No roles available",description:f?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:E.map(b=>{var _;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:b.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:b.permissions&&b.permissions.length>0?b.permissions.join(", "):""}),e.jsx(mt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:u===b.id,openChange:j=>g(j?b.id:null),children:[e.jsx(at,{children:e.jsx(Ll,{ref:j=>{j&&$.current.set(b.id,j)},disabled:!b.workspace_id,"data-role-dropdown-trigger":b.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{g(null);const j=$.current.get(b.id);l({isOpen:!0,role:b,triggerElement:j||null})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{g(null),x(b.id)},children:"Remove Role"})]})]}),v===b.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>y(b),onCancel:()=>x(null)}),h.isOpen&&((_=h.role)==null?void 0:_.id)===b.id&&e.jsx(si,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>{l({isOpen:!1}),g(null)},onSuccess:z})]})})]},b.id)})})]})})]})},Dl=()=>{const{activeWorkspace:t,loading:r}=Rt(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[p,f]=i.useState("info"),c=i.useCallback((h,l="info")=>{a(h),f(l),setTimeout(()=>a(null),3e3)},[]);return r?e.jsx(ai,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):t?e.jsx(Ps.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(l0,{children:e.jsxs(ai,{children:[e.jsx(d0,{children:e.jsxs(u0,{children:[e.jsx(xo,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(vo,{children:[e.jsx(er,{size:16}),"General"]})}),e.jsx(xo,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(vo,{children:[e.jsx(Uo,{size:16}),"Members"]})}),e.jsx(xo,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(vo,{children:[e.jsx($s,{size:16}),"Invitations"]})}),e.jsx(xo,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(vo,{children:[e.jsx(Qe,{size:16}),"Roles"]})})]})}),e.jsxs(p0,{children:[o==="general"&&e.jsx(m0,{}),o==="members"&&e.jsx(g0,{}),o==="invitations"&&e.jsx(f0,{}),o==="roles"&&e.jsx(x0,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):null},Nl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:p,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),p||f||e.jsx(Dl,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Fl=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:s=8})=>{const[a,p]=i.useState();return i.useEffect(()=>{if(!r||!t.current){p(void 0);return}const f=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),h=window.innerWidth,l=window.innerHeight,u=h-c.left,g=c.right,v=l-c.bottom,x=c.top;let w={};u>=o?w.left=c.left:g>=o?w.left=c.right-o:w.left=Math.max(s,Math.min(h-o-s,c.left)),v>=150?(w.top=c.bottom+s,w.maxHeight=Math.min(n,v-s*2)):x>=150?(w.bottom=l-c.top+s,w.maxHeight=Math.min(n,x-s*2)):(w.top=c.bottom+s,w.maxHeight=Math.max(100,v-s*2)),p(w)};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[r,o,n,s]),a},Bl=["organization:admin"],Ul=["organization:admin","organization:manage"],Wl=["workspace:admin"],Vl=["workspace:admin","workspace:manage"];function Os(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function Gl(t){return Os(t,Ul)}function v0(t){return Os(t,Bl)}function As(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function xs(t){return As(t,Vl)}function b0(t){return As(t,Wl)}const ii=d.div`
3340
3340
  position: relative;
3341
3341
  display: inline-block;
3342
3342
  width: 100%;
@@ -3380,7 +3380,7 @@ cursor: pointer;
3380
3380
  width: 100%;
3381
3381
  height: 100%;
3382
3382
  object-fit: cover;
3383
- `,ca=d.div`
3383
+ `,ci=d.div`
3384
3384
  display: flex;
3385
3385
  align-items: center;
3386
3386
  gap: 8px;
@@ -3454,7 +3454,7 @@ cursor: pointer;
3454
3454
  align-items: center;
3455
3455
  gap: 8px;
3456
3456
  flex: 1;
3457
- `,la=d.div`
3457
+ `,li=d.div`
3458
3458
  width: 20px;
3459
3459
  height: 20px;
3460
3460
  border-radius: 50%;
@@ -3467,7 +3467,7 @@ cursor: pointer;
3467
3467
  font-size: 10px;
3468
3468
  font-weight: 600;
3469
3469
  flex-shrink: 0;
3470
- `,da=d.img`
3470
+ `,di=d.img`
3471
3471
  width: 100%;
3472
3472
  height: 100%;
3473
3473
  object-fit: cover;
@@ -3513,7 +3513,7 @@ cursor: pointer;
3513
3513
  opacity: 0.5;
3514
3514
  cursor: not-allowed;
3515
3515
  }
3516
- `,ua=d.button`
3516
+ `,ui=d.button`
3517
3517
  display: flex;
3518
3518
  align-items: center;
3519
3519
  justify-content: space-between;
@@ -3572,7 +3572,7 @@ cursor: pointer;
3572
3572
  `,jo=d(Ao)`
3573
3573
  padding-left: 40px;
3574
3574
  font-size: 11px;
3575
- `,pa=d.div`
3575
+ `,pi=d.div`
3576
3576
  width: 16px;
3577
3577
  height: 16px;
3578
3578
  border-radius: 50%;
@@ -3585,7 +3585,7 @@ cursor: pointer;
3585
3585
  font-size: 9px;
3586
3586
  font-weight: 600;
3587
3587
  flex-shrink: 0;
3588
- `,ha=d.div`
3588
+ `,hi=d.div`
3589
3589
  padding: 8px 10px;
3590
3590
  border-radius: 4px;
3591
3591
  font-size: 10px;
@@ -3644,7 +3644,7 @@ cursor: pointer;
3644
3644
  background: var(--color-border);
3645
3645
  border-radius: 4px;
3646
3646
  width: ${t=>t.width||"100%"};
3647
- `,fa=d.div`
3647
+ `,fi=d.div`
3648
3648
  height: 10px;
3649
3649
  background: var(--color-border);
3650
3650
  border-radius: 4px;
@@ -3687,15 +3687,15 @@ cursor: pointer;
3687
3687
  height: 16px;
3688
3688
  background: var(--color-border);
3689
3689
  border-radius: 2px;
3690
- `,Hl=({showPersonal:t=!0})=>{var ue,U,pe,K;const[r,o]=a.useState(!1),[n,s]=a.useState(!1),[i,u]=a.useState(new Set),f=a.useRef(null),c=a.useRef(null),h=Fl({triggerRef:f,isOpen:r,minWidth:300}),l=Dr(!1),p=Dr(!1),g=Dr(!1),x=Dr(!1),[m,b]=a.useState(null),[$,z]=a.useState(!1),[w,y]=a.useState(null),{organizationMemberships:k,loading:C,refetch:_}=Ct(),{activeOrganization:v,activeMembership:P,leave:I}=Ze(),{activeWorkspace:S,activeMembership:T,leave:E}=Rt(),{workspaces:j,loading:R}=St(),{session:M,loading:F,switchOrganization:A,switchWorkspace:B}=Ue(),{deployment:O}=ve(),{toast:L}=He(),X=O==null?void 0:O.b2b_settings.organizations_enabled,ee=O==null?void 0:O.b2b_settings.workspaces_enabled,V=O==null?void 0:O.b2b_settings.allow_users_to_create_orgs,q=!((ue=M==null?void 0:M.active_signin)!=null&&ue.active_organization_membership_id),te=a.useMemo(()=>{var ne,me;if(q)return{name:"Personal account",image_url:(me=(ne=M==null?void 0:M.active_signin)==null?void 0:ne.user)==null?void 0:me.profile_picture_url,isPersonal:!0};let H=(v==null?void 0:v.name)||"";return ee&&S&&(H=`${v==null?void 0:v.name} / ${S.name}`),{name:H,image_url:v==null?void 0:v.image_url,isPersonal:!1}},[q,v,S,M,ee]);a.useEffect(()=>{if(!r)return;let H=null;const ne=setTimeout(()=>{const me=fe=>{var N,D;const W=fe.target;(N=f.current)!=null&&N.contains(W)||(D=c.current)!=null&&D.contains(W)||(o(!1),y(null))};document.addEventListener("mousedown",me),H=()=>{document.removeEventListener("mousedown",me)}},50);return()=>{clearTimeout(ne),H==null||H()}},[r]),a.useEffect(()=>{if(w){const H=setTimeout(()=>{y(null)},5e3);return()=>clearTimeout(H)}},[w]);const re=()=>{_()};if(!X)return null;const le=H=>{s(!0),A(H).finally(()=>{s(!1)})},oe=H=>{s(!0),B(H).finally(()=>{s(!1)})},de=H=>{const ne=new Set(i);ne.has(H)?ne.delete(H):ne.add(H),u(ne)},Z=H=>H.split(" ").map(ne=>ne[0]).join("").toUpperCase().slice(0,2),se=!!((U=M==null?void 0:M.active_signin)!=null&&U.active_organization_membership_id);return C||F||!k&&se?e.jsx(ge,{children:e.jsx(aa,{children:e.jsxs(E0,{children:[e.jsxs(ca,{children:[e.jsx(I0,{}),e.jsx(P0,{})]}),e.jsx(R0,{})]})})}):e.jsx(ge,{children:e.jsxs(aa,{children:[e.jsxs(y0,{ref:f,onClick:()=>{o(!r),r||y(null)},disabled:n,children:[e.jsxs(ca,{children:[e.jsx(w0,{children:te.image_url?e.jsx(j0,{src:te.image_url,alt:te.name}):te.isPersonal?e.jsx(Bo,{size:12}):Z(te.name)}),e.jsx(_0,{children:te.name})]}),e.jsx(Jp,{size:16})]}),typeof window<"u"&&Wr.createPortal(e.jsx(ge,{children:e.jsx(k0,{ref:c,$isOpen:r,$position:h,children:C||R?e.jsxs($0,{children:[e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsxs(Co,{children:[e.jsx(So,{width:"120px"}),e.jsx(fa,{width:"80px"})]})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsx(Co,{children:e.jsx(So,{width:"100px"})})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsxs(Co,{children:[e.jsx(So,{width:"140px"}),e.jsx(fa,{width:"60px"})]})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsx(Co,{children:e.jsx(So,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:q,onClick:H=>{H.stopPropagation(),q||le()},disabled:n||q,children:[q&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(C0,{children:(K=(pe=M==null?void 0:M.active_signin)==null?void 0:pe.user)!=null&&K.profile_picture_url?e.jsx(S0,{src:M.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Bo,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Personal account"})})]}),!q&&e.jsx(bo,{className:"hover-arrow",size:14})]}),!q&&v&&e.jsx(gr,{})]}),!q&&v&&e.jsxs(Ao,{$isActive:!0,onClick:()=>{ee&&de(v.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(wo,{}),e.jsxs(xt,{children:[ee&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:i.has(v.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(la,{children:v.image_url?e.jsx(da,{src:v.image_url,alt:v.name}):Z(v.name)}),e.jsx(vt,{children:e.jsx(bt,{children:v.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Gl(P)&&e.jsx(Lo,{onClick:H=>{H.stopPropagation(),p.open()},title:"Manage organization",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async H=>{H.stopPropagation(),z(!0),y(null);try{await I(),await _(),setTimeout(()=>{z(!1)},500)}catch(ne){y(ne instanceof Error?ne.message:"Failed to leave organization"),z(!1)}},disabled:$,title:"Leave organization",children:e.jsx(It,{size:12})})]})]}),v&&ee&&i.has(v.id)&&e.jsxs(e.Fragment,{children:[j==null?void 0:j.filter(H=>H.organization.id===v.id).map(H=>{const ne=(S==null?void 0:S.id)===H.id;return e.jsxs(jo,{as:ne?void 0:"button",$isActive:ne,onClick:ne?void 0:()=>oe(H.id),...ne?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[ne&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(pa,{children:H.image_url?e.jsx("img",{src:H.image_url,alt:H.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Z(H.name).charAt(0)}),e.jsx(vt,{children:e.jsx(bt,{children:H.name})})]}),ne?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[xs(T)&&e.jsx(Lo,{onClick:me=>{me.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async me=>{me.stopPropagation();try{E&&await E()}catch(fe){const W=fe.message||"Failed to leave workspace. Please try again.";L(W,"error")}},title:"Leave workspace",children:e.jsx(It,{size:12})})]}):e.jsx(bo,{className:"hover-arrow",size:14})]},H.id)}),e.jsx(jo,{as:"button",onClick:()=>{b(v.id),g.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{style:{width:"14px",height:"14px"},children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})})]}),($||w)&&e.jsxs(e.Fragment,{children:[$&&e.jsxs(ha,{children:[e.jsx(z0,{}),"Leaving organization..."]}),w&&e.jsxs(ha,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),w]})]}),e.jsx(gr,{}),k&&k.length>0&&e.jsx(e.Fragment,{children:k.filter(H=>H.organization.id!==(v==null?void 0:v.id)).map(H=>{const ne=H.organization,me=(j==null?void 0:j.filter(W=>W.organization.id===ne.id))||[],fe=i.has(ne.id);return e.jsxs(a.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:!1,onClick:()=>{ee?de(ne.id):le(ne.id)},disabled:n,children:[e.jsxs(xt,{children:[ee&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:fe?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(la,{children:ne.image_url?e.jsx(da,{src:ne.image_url,alt:ne.name}):Z(ne.name)}),e.jsx(vt,{children:e.jsx(bt,{children:ne.name})})]}),e.jsx(bo,{className:"hover-arrow",size:14})]}),ee&&fe&&e.jsxs(e.Fragment,{children:[me.map(W=>{const N=(S==null?void 0:S.id)===W.id;return e.jsxs(jo,{as:N?void 0:"button",$isActive:N,onClick:N?void 0:()=>oe(W.id),...N?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[N&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(pa,{children:W.image_url?e.jsx("img",{src:W.image_url,alt:W.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Z(W.name).charAt(0)}),e.jsx(vt,{children:e.jsx(bt,{children:W.name})})]}),N?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[xs(T)&&e.jsx(Lo,{onClick:D=>{D.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async D=>{D.stopPropagation();try{E&&await E()}catch(Y){const ie=Y.message||"Failed to leave workspace. Please try again.";L(ie,"error")}},title:"Leave workspace",children:e.jsx(It,{size:12})})]}):e.jsx(bo,{className:"hover-arrow",size:16})]},W.id)}),e.jsx(jo,{as:"button",onClick:()=>{b(ne.id),g.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{style:{width:"14px",height:"14px"},children:e.jsx(Ke,{size:10})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})})]}),e.jsx(gr,{})]},ne.id)})}),ee?v&&e.jsx(ua,{onClick:()=>{b(v.id),g.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})}):V&&e.jsx(ua,{onClick:()=>{l.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create organization"})})]})})]})})}),document.body),X&&V&&e.jsx(Nm,{isOpen:l.isOpen,onClose:l.close,onCreated:re}),e.jsx(Cx,{isOpen:p.isOpen,onClose:p.close}),e.jsx(Nl,{isOpen:x.isOpen,onClose:x.close}),m&&e.jsx(Al,{isOpen:g.isOpen,onClose:()=>{g.close(),b(null)},organizationId:m})]})})};var T0=Object.defineProperty,Go=Object.getOwnPropertySymbols,ql=Object.prototype.hasOwnProperty,Yl=Object.prototype.propertyIsEnumerable,ga=(t,r,o)=>r in t?T0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,vs=(t,r)=>{for(var o in r||(r={}))ql.call(r,o)&&ga(t,o,r[o]);if(Go)for(var o of Go(r))Yl.call(r,o)&&ga(t,o,r[o]);return t},bs=(t,r)=>{var o={};for(var n in t)ql.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Go)for(var n of Go(t))r.indexOf(n)<0&&Yl.call(t,n)&&(o[n]=t[n]);return o};/**
3690
+ `,Hl=({showPersonal:t=!0})=>{var ue,U,pe,K;const[r,o]=i.useState(!1),[n,s]=i.useState(!1),[a,p]=i.useState(new Set),f=i.useRef(null),c=i.useRef(null),h=Fl({triggerRef:f,isOpen:r,minWidth:300}),l=Dr(!1),u=Dr(!1),g=Dr(!1),v=Dr(!1),[x,w]=i.useState(null),[$,S]=i.useState(!1),[k,P]=i.useState(null),{organizationMemberships:E,loading:z,refetch:y}=Ct(),{activeOrganization:m,activeMembership:b,leave:_}=Ze(),{activeWorkspace:j,activeMembership:T,leave:R}=Rt(),{workspaces:C,loading:I}=Pt(),{session:M,loading:F,switchOrganization:L,switchWorkspace:B}=Ue(),{deployment:O}=ve(),{toast:A}=He(),X=O==null?void 0:O.b2b_settings.organizations_enabled,te=O==null?void 0:O.b2b_settings.workspaces_enabled,V=O==null?void 0:O.b2b_settings.allow_users_to_create_orgs,q=!((ue=M==null?void 0:M.active_signin)!=null&&ue.active_organization_membership_id),re=i.useMemo(()=>{var se,me;if(q)return{name:"Personal account",image_url:(me=(se=M==null?void 0:M.active_signin)==null?void 0:se.user)==null?void 0:me.profile_picture_url,isPersonal:!0};let H=(m==null?void 0:m.name)||"";return te&&j&&(H=`${m==null?void 0:m.name} / ${j.name}`),{name:H,image_url:m==null?void 0:m.image_url,isPersonal:!1}},[q,m,j,M,te]);i.useEffect(()=>{if(!r)return;let H=null;const se=setTimeout(()=>{const me=fe=>{var N,D;const W=fe.target;(N=f.current)!=null&&N.contains(W)||(D=c.current)!=null&&D.contains(W)||(o(!1),P(null))};document.addEventListener("mousedown",me),H=()=>{document.removeEventListener("mousedown",me)}},50);return()=>{clearTimeout(se),H==null||H()}},[r]),i.useEffect(()=>{if(k){const H=setTimeout(()=>{P(null)},5e3);return()=>clearTimeout(H)}},[k]);const ne=()=>{y()};if(!X)return null;const J=H=>{s(!0),L(H).finally(()=>{s(!1)})},oe=H=>{s(!0),B(H).finally(()=>{s(!1)})},de=H=>{const se=new Set(a);se.has(H)?se.delete(H):se.add(H),p(se)},Z=H=>H.split(" ").map(se=>se[0]).join("").toUpperCase().slice(0,2),ae=!!((U=M==null?void 0:M.active_signin)!=null&&U.active_organization_membership_id);return z||F||!E&&ae?e.jsx(ge,{children:e.jsx(ii,{children:e.jsxs(E0,{children:[e.jsxs(ci,{children:[e.jsx(I0,{}),e.jsx(P0,{})]}),e.jsx(R0,{})]})})}):e.jsx(ge,{children:e.jsxs(ii,{children:[e.jsxs(y0,{ref:f,onClick:()=>{o(!r),r||P(null)},disabled:n,children:[e.jsxs(ci,{children:[e.jsx(w0,{children:re.image_url?e.jsx(j0,{src:re.image_url,alt:re.name}):re.isPersonal?e.jsx(Bo,{size:12}):Z(re.name)}),e.jsx(_0,{children:re.name})]}),e.jsx(Jp,{size:16})]}),typeof window<"u"&&Wr.createPortal(e.jsx(ge,{children:e.jsx(k0,{ref:c,$isOpen:r,$position:h,children:z||I?e.jsxs($0,{children:[e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsxs(Co,{children:[e.jsx(So,{width:"120px"}),e.jsx(fi,{width:"80px"})]})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsx(Co,{children:e.jsx(So,{width:"100px"})})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsxs(Co,{children:[e.jsx(So,{width:"140px"}),e.jsx(fi,{width:"60px"})]})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsx(Co,{children:e.jsx(So,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:q,onClick:H=>{H.stopPropagation(),q||J()},disabled:n||q,children:[q&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(C0,{children:(K=(pe=M==null?void 0:M.active_signin)==null?void 0:pe.user)!=null&&K.profile_picture_url?e.jsx(S0,{src:M.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Bo,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Personal account"})})]}),!q&&e.jsx(bo,{className:"hover-arrow",size:14})]}),!q&&m&&e.jsx(gr,{})]}),!q&&m&&e.jsxs(Ao,{$isActive:!0,onClick:()=>{te&&de(m.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(wo,{}),e.jsxs(xt,{children:[te&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:a.has(m.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(li,{children:m.image_url?e.jsx(di,{src:m.image_url,alt:m.name}):Z(m.name)}),e.jsx(vt,{children:e.jsx(bt,{children:m.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Gl(b)&&e.jsx(Lo,{onClick:H=>{H.stopPropagation(),u.open()},title:"Manage organization",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async H=>{H.stopPropagation(),S(!0),P(null);try{await _(),await y(),setTimeout(()=>{S(!1)},500)}catch(se){P(se instanceof Error?se.message:"Failed to leave organization"),S(!1)}},disabled:$,title:"Leave organization",children:e.jsx(Et,{size:12})})]})]}),m&&te&&a.has(m.id)&&e.jsxs(e.Fragment,{children:[C==null?void 0:C.filter(H=>H.organization.id===m.id).map(H=>{const se=(j==null?void 0:j.id)===H.id;return e.jsxs(jo,{as:se?void 0:"button",$isActive:se,onClick:se?void 0:()=>oe(H.id),...se?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[se&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(pi,{children:H.image_url?e.jsx("img",{src:H.image_url,alt:H.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Z(H.name).charAt(0)}),e.jsx(vt,{children:e.jsx(bt,{children:H.name})})]}),se?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[xs(T)&&e.jsx(Lo,{onClick:me=>{me.stopPropagation(),v.open()},title:"Manage workspace",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async me=>{me.stopPropagation();try{R&&await R()}catch(fe){const W=fe.message||"Failed to leave workspace. Please try again.";A(W,"error")}},title:"Leave workspace",children:e.jsx(Et,{size:12})})]}):e.jsx(bo,{className:"hover-arrow",size:14})]},H.id)}),e.jsx(jo,{as:"button",onClick:()=>{w(m.id),g.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{style:{width:"14px",height:"14px"},children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})})]}),($||k)&&e.jsxs(e.Fragment,{children:[$&&e.jsxs(hi,{children:[e.jsx(z0,{}),"Leaving organization..."]}),k&&e.jsxs(hi,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),k]})]}),e.jsx(gr,{}),E&&E.length>0&&e.jsx(e.Fragment,{children:E.filter(H=>H.organization.id!==(m==null?void 0:m.id)).map(H=>{const se=H.organization,me=(C==null?void 0:C.filter(W=>W.organization.id===se.id))||[],fe=a.has(se.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:!1,onClick:()=>{te?de(se.id):J(se.id)},disabled:n,children:[e.jsxs(xt,{children:[te&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:fe?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(li,{children:se.image_url?e.jsx(di,{src:se.image_url,alt:se.name}):Z(se.name)}),e.jsx(vt,{children:e.jsx(bt,{children:se.name})})]}),e.jsx(bo,{className:"hover-arrow",size:14})]}),te&&fe&&e.jsxs(e.Fragment,{children:[me.map(W=>{const N=(j==null?void 0:j.id)===W.id;return e.jsxs(jo,{as:N?void 0:"button",$isActive:N,onClick:N?void 0:()=>oe(W.id),...N?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[N&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(pi,{children:W.image_url?e.jsx("img",{src:W.image_url,alt:W.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Z(W.name).charAt(0)}),e.jsx(vt,{children:e.jsx(bt,{children:W.name})})]}),N?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[xs(T)&&e.jsx(Lo,{onClick:D=>{D.stopPropagation(),v.open()},title:"Manage workspace",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async D=>{D.stopPropagation();try{R&&await R()}catch(Y){const ie=Y.message||"Failed to leave workspace. Please try again.";A(ie,"error")}},title:"Leave workspace",children:e.jsx(Et,{size:12})})]}):e.jsx(bo,{className:"hover-arrow",size:16})]},W.id)}),e.jsx(jo,{as:"button",onClick:()=>{w(se.id),g.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{style:{width:"14px",height:"14px"},children:e.jsx(Ke,{size:10})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})})]}),e.jsx(gr,{})]},se.id)})}),te?m&&e.jsx(ui,{onClick:()=>{w(m.id),g.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})}):V&&e.jsx(ui,{onClick:()=>{l.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create organization"})})]})})]})})}),document.body),X&&V&&e.jsx(Nm,{isOpen:l.isOpen,onClose:l.close,onCreated:ne}),e.jsx(Cx,{isOpen:u.isOpen,onClose:u.close}),e.jsx(Nl,{isOpen:v.isOpen,onClose:v.close}),x&&e.jsx(Al,{isOpen:g.isOpen,onClose:()=>{g.close(),w(null)},organizationId:x})]})})};var T0=Object.defineProperty,Go=Object.getOwnPropertySymbols,ql=Object.prototype.hasOwnProperty,Yl=Object.prototype.propertyIsEnumerable,gi=(t,r,o)=>r in t?T0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,vs=(t,r)=>{for(var o in r||(r={}))ql.call(r,o)&&gi(t,o,r[o]);if(Go)for(var o of Go(r))Yl.call(r,o)&&gi(t,o,r[o]);return t},bs=(t,r)=>{var o={};for(var n in t)ql.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Go)for(var n of Go(t))r.indexOf(n)<0&&Yl.call(t,n)&&(o[n]=t[n]);return o};/**
3691
3691
  * @license QR Code generator library (TypeScript)
3692
3692
  * Copyright (c) Project Nayuki.
3693
3693
  * SPDX-License-Identifier: MIT
3694
- */var nr;(t=>{const r=class je{constructor(c,h,l,p){if(this.version=c,this.errorCorrectionLevel=h,this.modules=[],this.isFunction=[],c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version value out of range");if(p<-1||p>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let g=[];for(let m=0;m<this.size;m++)g.push(!1);for(let m=0;m<this.size;m++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(l);if(this.drawCodewords(x),p==-1){let m=1e9;for(let b=0;b<8;b++){this.applyMask(b),this.drawFormatBits(b);const $=this.getPenaltyScore();$<m&&(p=b,m=$),this.applyMask(b)}}s(0<=p&&p<=7),this.mask=p,this.applyMask(p),this.drawFormatBits(p),this.isFunction=[]}static encodeText(c,h){const l=t.QrSegment.makeSegments(c);return je.encodeSegments(l,h)}static encodeBinary(c,h){const l=t.QrSegment.makeBytes(c);return je.encodeSegments([l],h)}static encodeSegments(c,h,l=1,p=40,g=-1,x=!0){if(!(je.MIN_VERSION<=l&&l<=p&&p<=je.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let m,b;for(m=l;;m++){const y=je.getNumDataCodewords(m,h)*8,k=u.getTotalBits(c,m);if(k<=y){b=k;break}if(m>=p)throw new RangeError("Data too long")}for(const y of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])x&&b<=je.getNumDataCodewords(m,y)*8&&(h=y);let $=[];for(const y of c){o(y.mode.modeBits,4,$),o(y.numChars,y.mode.numCharCountBits(m),$);for(const k of y.getData())$.push(k)}s($.length==b);const z=je.getNumDataCodewords(m,h)*8;s($.length<=z),o(0,Math.min(4,z-$.length),$),o(0,(8-$.length%8)%8,$),s($.length%8==0);for(let y=236;$.length<z;y^=253)o(y,8,$);let w=[];for(;w.length*8<$.length;)w.push(0);return $.forEach((y,k)=>w[k>>>3]|=y<<7-(k&7)),new je(m,h,w,g)}getModule(c,h){return 0<=c&&c<this.size&&0<=h&&h<this.size&&this.modules[h][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),h=c.length;for(let l=0;l<h;l++)for(let p=0;p<h;p++)l==0&&p==0||l==0&&p==h-1||l==h-1&&p==0||this.drawAlignmentPattern(c[l],c[p]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const h=this.errorCorrectionLevel.formatBits<<3|c;let l=h;for(let g=0;g<10;g++)l=l<<1^(l>>>9)*1335;const p=(h<<10|l)^21522;s(p>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(p,g));this.setFunctionModule(8,7,n(p,6)),this.setFunctionModule(8,8,n(p,7)),this.setFunctionModule(7,8,n(p,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(p,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(p,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(p,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let l=0;l<12;l++)c=c<<1^(c>>>11)*7973;const h=this.version<<12|c;s(h>>>18==0);for(let l=0;l<18;l++){const p=n(h,l),g=this.size-11+l%3,x=Math.floor(l/3);this.setFunctionModule(g,x,p),this.setFunctionModule(x,g,p)}}drawFinderPattern(c,h){for(let l=-4;l<=4;l++)for(let p=-4;p<=4;p++){const g=Math.max(Math.abs(p),Math.abs(l)),x=c+p,m=h+l;0<=x&&x<this.size&&0<=m&&m<this.size&&this.setFunctionModule(x,m,g!=2&&g!=4)}}drawAlignmentPattern(c,h){for(let l=-2;l<=2;l++)for(let p=-2;p<=2;p++)this.setFunctionModule(c+p,h+l,Math.max(Math.abs(p),Math.abs(l))!=1)}setFunctionModule(c,h,l){this.modules[h][c]=l,this.isFunction[h][c]=!0}addEccAndInterleave(c){const h=this.version,l=this.errorCorrectionLevel;if(c.length!=je.getNumDataCodewords(h,l))throw new RangeError("Invalid argument");const p=je.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][h],g=je.ECC_CODEWORDS_PER_BLOCK[l.ordinal][h],x=Math.floor(je.getNumRawDataModules(h)/8),m=p-x%p,b=Math.floor(x/p);let $=[];const z=je.reedSolomonComputeDivisor(g);for(let y=0,k=0;y<p;y++){let C=c.slice(k,k+b-g+(y<m?0:1));k+=C.length;const _=je.reedSolomonComputeRemainder(C,z);y<m&&C.push(0),$.push(C.concat(_))}let w=[];for(let y=0;y<$[0].length;y++)$.forEach((k,C)=>{(y!=b-g||C>=m)&&w.push(k[y])});return s(w.length==x),w}drawCodewords(c){if(c.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let h=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let p=0;p<this.size;p++)for(let g=0;g<2;g++){const x=l-g,b=(l+1&2)==0?this.size-1-p:p;!this.isFunction[b][x]&&h<c.length*8&&(this.modules[b][x]=n(c[h>>>3],7-(h&7)),h++)}}s(h==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let h=0;h<this.size;h++)for(let l=0;l<this.size;l++){let p;switch(c){case 0:p=(l+h)%2==0;break;case 1:p=h%2==0;break;case 2:p=l%3==0;break;case 3:p=(l+h)%3==0;break;case 4:p=(Math.floor(l/3)+Math.floor(h/2))%2==0;break;case 5:p=l*h%2+l*h%3==0;break;case 6:p=(l*h%2+l*h%3)%2==0;break;case 7:p=((l+h)%2+l*h%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[h][l]&&p&&(this.modules[h][l]=!this.modules[h][l])}}getPenaltyScore(){let c=0;for(let g=0;g<this.size;g++){let x=!1,m=0,b=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[g][$]==x?(m++,m==5?c+=je.PENALTY_N1:m>5&&c++):(this.finderPenaltyAddHistory(m,b),x||(c+=this.finderPenaltyCountPatterns(b)*je.PENALTY_N3),x=this.modules[g][$],m=1);c+=this.finderPenaltyTerminateAndCount(x,m,b)*je.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,m=0,b=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[$][g]==x?(m++,m==5?c+=je.PENALTY_N1:m>5&&c++):(this.finderPenaltyAddHistory(m,b),x||(c+=this.finderPenaltyCountPatterns(b)*je.PENALTY_N3),x=this.modules[$][g],m=1);c+=this.finderPenaltyTerminateAndCount(x,m,b)*je.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const m=this.modules[g][x];m==this.modules[g][x+1]&&m==this.modules[g+1][x]&&m==this.modules[g+1][x+1]&&(c+=je.PENALTY_N2)}let h=0;for(const g of this.modules)h=g.reduce((x,m)=>x+(m?1:0),h);const l=this.size*this.size,p=Math.ceil(Math.abs(h*20-l*10)/l)-1;return s(0<=p&&p<=9),c+=p*je.PENALTY_N4,s(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,h=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let l=[6];for(let p=this.size-7;l.length<c;p-=h)l.splice(1,0,p);return l}}static getNumRawDataModules(c){if(c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version number out of range");let h=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;h-=(25*l-10)*l-55,c>=7&&(h-=36)}return s(208<=h&&h<=29648),h}static getNumDataCodewords(c,h){return Math.floor(je.getNumRawDataModules(c)/8)-je.ECC_CODEWORDS_PER_BLOCK[h.ordinal][c]*je.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let h=[];for(let p=0;p<c-1;p++)h.push(0);h.push(1);let l=1;for(let p=0;p<c;p++){for(let g=0;g<h.length;g++)h[g]=je.reedSolomonMultiply(h[g],l),g+1<h.length&&(h[g]^=h[g+1]);l=je.reedSolomonMultiply(l,2)}return h}static reedSolomonComputeRemainder(c,h){let l=h.map(p=>0);for(const p of c){const g=p^l.shift();l.push(0),h.forEach((x,m)=>l[m]^=je.reedSolomonMultiply(x,g))}return l}static reedSolomonMultiply(c,h){if(c>>>8||h>>>8)throw new RangeError("Byte out of range");let l=0;for(let p=7;p>=0;p--)l=l<<1^(l>>>7)*285,l^=(h>>>p&1)*c;return s(l>>>8==0),l}finderPenaltyCountPatterns(c){const h=c[1];s(h<=this.size*3);const l=h>0&&c[2]==h&&c[3]==h*3&&c[4]==h&&c[5]==h;return(l&&c[0]>=h*4&&c[6]>=h?1:0)+(l&&c[6]>=h*4&&c[0]>=h?1:0)}finderPenaltyTerminateAndCount(c,h,l){return c&&(this.finderPenaltyAddHistory(h,l),h=0),h+=this.size,this.finderPenaltyAddHistory(h,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(c,h){h[0]==0&&(c+=this.size),h.pop(),h.unshift(c)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function o(f,c,h){if(c<0||c>31||f>>>c)throw new RangeError("Value out of range");for(let l=c-1;l>=0;l--)h.push(f>>>l&1)}function n(f,c){return(f>>>c&1)!=0}function s(f){if(!f)throw new Error("Assertion error")}const i=class Oe{constructor(c,h,l){if(this.mode=c,this.numChars=h,this.bitData=l,h<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let h=[];for(const l of c)o(l,8,h);return new Oe(Oe.Mode.BYTE,c.length,h)}static makeNumeric(c){if(!Oe.isNumeric(c))throw new RangeError("String contains non-numeric characters");let h=[];for(let l=0;l<c.length;){const p=Math.min(c.length-l,3);o(parseInt(c.substring(l,l+p),10),p*3+1,h),l+=p}return new Oe(Oe.Mode.NUMERIC,c.length,h)}static makeAlphanumeric(c){if(!Oe.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let h=[],l;for(l=0;l+2<=c.length;l+=2){let p=Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;p+=Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),o(p,11,h)}return l<c.length&&o(Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,h),new Oe(Oe.Mode.ALPHANUMERIC,c.length,h)}static makeSegments(c){return c==""?[]:Oe.isNumeric(c)?[Oe.makeNumeric(c)]:Oe.isAlphanumeric(c)?[Oe.makeAlphanumeric(c)]:[Oe.makeBytes(Oe.toUtf8ByteArray(c))]}static makeEci(c){let h=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,h);else if(c<16384)o(2,2,h),o(c,14,h);else if(c<1e6)o(6,3,h),o(c,21,h);else throw new RangeError("ECI assignment value out of range");return new Oe(Oe.Mode.ECI,0,h)}static isNumeric(c){return Oe.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Oe.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,h){let l=0;for(const p of c){const g=p.mode.numCharCountBits(h);if(p.numChars>=1<<g)return 1/0;l+=4+g+p.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let h=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?h.push(c.charCodeAt(l)):(h.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return h}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let u=i;t.QrSegment=i})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(nr||(nr={}));var vr=nr;/**
3694
+ */var nr;(t=>{const r=class je{constructor(c,h,l,u){if(this.version=c,this.errorCorrectionLevel=h,this.modules=[],this.isFunction=[],c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version value out of range");if(u<-1||u>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let g=[];for(let x=0;x<this.size;x++)g.push(!1);for(let x=0;x<this.size;x++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(l);if(this.drawCodewords(v),u==-1){let x=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const $=this.getPenaltyScore();$<x&&(u=w,x=$),this.applyMask(w)}}s(0<=u&&u<=7),this.mask=u,this.applyMask(u),this.drawFormatBits(u),this.isFunction=[]}static encodeText(c,h){const l=t.QrSegment.makeSegments(c);return je.encodeSegments(l,h)}static encodeBinary(c,h){const l=t.QrSegment.makeBytes(c);return je.encodeSegments([l],h)}static encodeSegments(c,h,l=1,u=40,g=-1,v=!0){if(!(je.MIN_VERSION<=l&&l<=u&&u<=je.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let x,w;for(x=l;;x++){const P=je.getNumDataCodewords(x,h)*8,E=p.getTotalBits(c,x);if(E<=P){w=E;break}if(x>=u)throw new RangeError("Data too long")}for(const P of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])v&&w<=je.getNumDataCodewords(x,P)*8&&(h=P);let $=[];for(const P of c){o(P.mode.modeBits,4,$),o(P.numChars,P.mode.numCharCountBits(x),$);for(const E of P.getData())$.push(E)}s($.length==w);const S=je.getNumDataCodewords(x,h)*8;s($.length<=S),o(0,Math.min(4,S-$.length),$),o(0,(8-$.length%8)%8,$),s($.length%8==0);for(let P=236;$.length<S;P^=253)o(P,8,$);let k=[];for(;k.length*8<$.length;)k.push(0);return $.forEach((P,E)=>k[E>>>3]|=P<<7-(E&7)),new je(x,h,k,g)}getModule(c,h){return 0<=c&&c<this.size&&0<=h&&h<this.size&&this.modules[h][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),h=c.length;for(let l=0;l<h;l++)for(let u=0;u<h;u++)l==0&&u==0||l==0&&u==h-1||l==h-1&&u==0||this.drawAlignmentPattern(c[l],c[u]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const h=this.errorCorrectionLevel.formatBits<<3|c;let l=h;for(let g=0;g<10;g++)l=l<<1^(l>>>9)*1335;const u=(h<<10|l)^21522;s(u>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(u,g));this.setFunctionModule(8,7,n(u,6)),this.setFunctionModule(8,8,n(u,7)),this.setFunctionModule(7,8,n(u,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(u,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(u,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(u,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let l=0;l<12;l++)c=c<<1^(c>>>11)*7973;const h=this.version<<12|c;s(h>>>18==0);for(let l=0;l<18;l++){const u=n(h,l),g=this.size-11+l%3,v=Math.floor(l/3);this.setFunctionModule(g,v,u),this.setFunctionModule(v,g,u)}}drawFinderPattern(c,h){for(let l=-4;l<=4;l++)for(let u=-4;u<=4;u++){const g=Math.max(Math.abs(u),Math.abs(l)),v=c+u,x=h+l;0<=v&&v<this.size&&0<=x&&x<this.size&&this.setFunctionModule(v,x,g!=2&&g!=4)}}drawAlignmentPattern(c,h){for(let l=-2;l<=2;l++)for(let u=-2;u<=2;u++)this.setFunctionModule(c+u,h+l,Math.max(Math.abs(u),Math.abs(l))!=1)}setFunctionModule(c,h,l){this.modules[h][c]=l,this.isFunction[h][c]=!0}addEccAndInterleave(c){const h=this.version,l=this.errorCorrectionLevel;if(c.length!=je.getNumDataCodewords(h,l))throw new RangeError("Invalid argument");const u=je.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][h],g=je.ECC_CODEWORDS_PER_BLOCK[l.ordinal][h],v=Math.floor(je.getNumRawDataModules(h)/8),x=u-v%u,w=Math.floor(v/u);let $=[];const S=je.reedSolomonComputeDivisor(g);for(let P=0,E=0;P<u;P++){let z=c.slice(E,E+w-g+(P<x?0:1));E+=z.length;const y=je.reedSolomonComputeRemainder(z,S);P<x&&z.push(0),$.push(z.concat(y))}let k=[];for(let P=0;P<$[0].length;P++)$.forEach((E,z)=>{(P!=w-g||z>=x)&&k.push(E[P])});return s(k.length==v),k}drawCodewords(c){if(c.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let h=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let u=0;u<this.size;u++)for(let g=0;g<2;g++){const v=l-g,w=(l+1&2)==0?this.size-1-u:u;!this.isFunction[w][v]&&h<c.length*8&&(this.modules[w][v]=n(c[h>>>3],7-(h&7)),h++)}}s(h==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let h=0;h<this.size;h++)for(let l=0;l<this.size;l++){let u;switch(c){case 0:u=(l+h)%2==0;break;case 1:u=h%2==0;break;case 2:u=l%3==0;break;case 3:u=(l+h)%3==0;break;case 4:u=(Math.floor(l/3)+Math.floor(h/2))%2==0;break;case 5:u=l*h%2+l*h%3==0;break;case 6:u=(l*h%2+l*h%3)%2==0;break;case 7:u=((l+h)%2+l*h%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[h][l]&&u&&(this.modules[h][l]=!this.modules[h][l])}}getPenaltyScore(){let c=0;for(let g=0;g<this.size;g++){let v=!1,x=0,w=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[g][$]==v?(x++,x==5?c+=je.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,w),v||(c+=this.finderPenaltyCountPatterns(w)*je.PENALTY_N3),v=this.modules[g][$],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,w)*je.PENALTY_N3}for(let g=0;g<this.size;g++){let v=!1,x=0,w=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[$][g]==v?(x++,x==5?c+=je.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,w),v||(c+=this.finderPenaltyCountPatterns(w)*je.PENALTY_N3),v=this.modules[$][g],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,w)*je.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let v=0;v<this.size-1;v++){const x=this.modules[g][v];x==this.modules[g][v+1]&&x==this.modules[g+1][v]&&x==this.modules[g+1][v+1]&&(c+=je.PENALTY_N2)}let h=0;for(const g of this.modules)h=g.reduce((v,x)=>v+(x?1:0),h);const l=this.size*this.size,u=Math.ceil(Math.abs(h*20-l*10)/l)-1;return s(0<=u&&u<=9),c+=u*je.PENALTY_N4,s(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,h=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let l=[6];for(let u=this.size-7;l.length<c;u-=h)l.splice(1,0,u);return l}}static getNumRawDataModules(c){if(c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version number out of range");let h=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;h-=(25*l-10)*l-55,c>=7&&(h-=36)}return s(208<=h&&h<=29648),h}static getNumDataCodewords(c,h){return Math.floor(je.getNumRawDataModules(c)/8)-je.ECC_CODEWORDS_PER_BLOCK[h.ordinal][c]*je.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let h=[];for(let u=0;u<c-1;u++)h.push(0);h.push(1);let l=1;for(let u=0;u<c;u++){for(let g=0;g<h.length;g++)h[g]=je.reedSolomonMultiply(h[g],l),g+1<h.length&&(h[g]^=h[g+1]);l=je.reedSolomonMultiply(l,2)}return h}static reedSolomonComputeRemainder(c,h){let l=h.map(u=>0);for(const u of c){const g=u^l.shift();l.push(0),h.forEach((v,x)=>l[x]^=je.reedSolomonMultiply(v,g))}return l}static reedSolomonMultiply(c,h){if(c>>>8||h>>>8)throw new RangeError("Byte out of range");let l=0;for(let u=7;u>=0;u--)l=l<<1^(l>>>7)*285,l^=(h>>>u&1)*c;return s(l>>>8==0),l}finderPenaltyCountPatterns(c){const h=c[1];s(h<=this.size*3);const l=h>0&&c[2]==h&&c[3]==h*3&&c[4]==h&&c[5]==h;return(l&&c[0]>=h*4&&c[6]>=h?1:0)+(l&&c[6]>=h*4&&c[0]>=h?1:0)}finderPenaltyTerminateAndCount(c,h,l){return c&&(this.finderPenaltyAddHistory(h,l),h=0),h+=this.size,this.finderPenaltyAddHistory(h,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(c,h){h[0]==0&&(c+=this.size),h.pop(),h.unshift(c)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function o(f,c,h){if(c<0||c>31||f>>>c)throw new RangeError("Value out of range");for(let l=c-1;l>=0;l--)h.push(f>>>l&1)}function n(f,c){return(f>>>c&1)!=0}function s(f){if(!f)throw new Error("Assertion error")}const a=class Oe{constructor(c,h,l){if(this.mode=c,this.numChars=h,this.bitData=l,h<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let h=[];for(const l of c)o(l,8,h);return new Oe(Oe.Mode.BYTE,c.length,h)}static makeNumeric(c){if(!Oe.isNumeric(c))throw new RangeError("String contains non-numeric characters");let h=[];for(let l=0;l<c.length;){const u=Math.min(c.length-l,3);o(parseInt(c.substring(l,l+u),10),u*3+1,h),l+=u}return new Oe(Oe.Mode.NUMERIC,c.length,h)}static makeAlphanumeric(c){if(!Oe.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let h=[],l;for(l=0;l+2<=c.length;l+=2){let u=Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;u+=Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),o(u,11,h)}return l<c.length&&o(Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,h),new Oe(Oe.Mode.ALPHANUMERIC,c.length,h)}static makeSegments(c){return c==""?[]:Oe.isNumeric(c)?[Oe.makeNumeric(c)]:Oe.isAlphanumeric(c)?[Oe.makeAlphanumeric(c)]:[Oe.makeBytes(Oe.toUtf8ByteArray(c))]}static makeEci(c){let h=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,h);else if(c<16384)o(2,2,h),o(c,14,h);else if(c<1e6)o(6,3,h),o(c,21,h);else throw new RangeError("ECI assignment value out of range");return new Oe(Oe.Mode.ECI,0,h)}static isNumeric(c){return Oe.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Oe.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,h){let l=0;for(const u of c){const g=u.mode.numCharCountBits(h);if(u.numChars>=1<<g)return 1/0;l+=4+g+u.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let h=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?h.push(c.charCodeAt(l)):(h.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return h}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let p=a;t.QrSegment=a})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(s,a){this.ordinal=s,this.formatBits=a}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(s,a){this.modeBits=s,this.numBitsCharCount=a}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(nr||(nr={}));var vr=nr;/**
3695
3695
  * @license qrcode.react
3696
3696
  * Copyright (c) Paul O'Shannessy
3697
3697
  * SPDX-License-Identifier: ISC
3698
- */var M0={L:vr.QrCode.Ecc.LOW,M:vr.QrCode.Ecc.MEDIUM,Q:vr.QrCode.Ecc.QUARTILE,H:vr.QrCode.Ecc.HIGH},Zl=128,Kl="L",Ql="#FFFFFF",Xl="#000000",Jl=!1,ed=1,O0=4,A0=0,L0=.1;function td(t,r=0){const o=[];return t.forEach(function(n,s){let i=null;n.forEach(function(u,f){if(!u&&i!==null){o.push(`M${i+r} ${s+r}h${f-i}v1H${i+r}z`),i=null;return}if(f===n.length-1){if(!u)return;i===null?o.push(`M${f+r},${s+r} h1v1H${f+r}z`):o.push(`M${i+r},${s+r} h${f+1-i}v1H${i+r}z`);return}u&&i===null&&(i=f)})}),o.join("")}function rd(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((s,i)=>i<r.x||i>=r.x+r.w?s:!1))}function D0(t,r,o,n){if(n==null)return null;const s=t.length+o*2,i=Math.floor(r*L0),u=s/r,f=(n.width||i)*u,c=(n.height||i)*u,h=n.x==null?t.length/2-f/2:n.x*u,l=n.y==null?t.length/2-c/2:n.y*u,p=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let m=Math.floor(h),b=Math.floor(l),$=Math.ceil(f+h-m),z=Math.ceil(c+l-b);g={x:m,y:b,w:$,h:z}}const x=n.crossOrigin;return{x:h,y:l,h:c,w:f,excavation:g,opacity:p,crossOrigin:x}}function N0(t,r){return r!=null?Math.max(Math.floor(r),0):t?O0:A0}function od({value:t,level:r,minVersion:o,includeMargin:n,marginSize:s,imageSettings:i,size:u,boostLevel:f}){let c=a.useMemo(()=>{const m=(Array.isArray(t)?t:[t]).reduce((b,$)=>(b.push(...vr.QrSegment.makeSegments($)),b),[]);return vr.QrCode.encodeSegments(m,M0[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:h,margin:l,numCells:p,calculatedImageSettings:g}=a.useMemo(()=>{let x=c.getModules();const m=N0(n,s),b=x.length+m*2,$=D0(x,u,m,i);return{cells:x,margin:m,numCells:b,calculatedImageSettings:$}},[c,u,i,n,s]);return{qrcode:c,margin:l,cells:h,numCells:p,calculatedImageSettings:g}}var F0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),B0=a.forwardRef(function(r,o){const n=r,{value:s,size:i=Zl,level:u=Kl,bgColor:f=Ql,fgColor:c=Xl,includeMargin:h=Jl,minVersion:l=ed,boostLevel:p,marginSize:g,imageSettings:x}=n,b=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:$}=b,z=bs(b,["style"]),w=x==null?void 0:x.src,y=a.useRef(null),k=a.useRef(null),C=a.useCallback(R=>{y.current=R,typeof o=="function"?o(R):o&&(o.current=R)},[o]),[_,v]=a.useState(!1),{margin:P,cells:I,numCells:S,calculatedImageSettings:T}=od({value:s,level:u,minVersion:l,boostLevel:p,includeMargin:h,marginSize:g,imageSettings:x,size:i});a.useEffect(()=>{if(y.current!=null){const R=y.current,M=R.getContext("2d");if(!M)return;let F=I;const A=k.current,B=T!=null&&A!==null&&A.complete&&A.naturalHeight!==0&&A.naturalWidth!==0;B&&T.excavation!=null&&(F=rd(I,T.excavation));const O=window.devicePixelRatio||1;R.height=R.width=i*O;const L=i/S*O;M.scale(L,L),M.fillStyle=f,M.fillRect(0,0,S,S),M.fillStyle=c,F0?M.fill(new Path2D(td(F,P))):I.forEach(function(X,ee){X.forEach(function(V,q){V&&M.fillRect(q+P,ee+P,1,1)})}),T&&(M.globalAlpha=T.opacity),B&&M.drawImage(A,T.x+P,T.y+P,T.w,T.h)}}),a.useEffect(()=>{v(!1)},[w]);const E=vs({height:i,width:i},$);let j=null;return w!=null&&(j=a.createElement("img",{src:w,key:w,style:{display:"none"},onLoad:()=>{v(!0)},ref:k,crossOrigin:T==null?void 0:T.crossOrigin})),a.createElement(a.Fragment,null,a.createElement("canvas",vs({style:E,height:i,width:i,ref:C,role:"img"},z)),j)});B0.displayName="QRCodeCanvas";var Ls=a.forwardRef(function(r,o){const n=r,{value:s,size:i=Zl,level:u=Kl,bgColor:f=Ql,fgColor:c=Xl,includeMargin:h=Jl,minVersion:l=ed,boostLevel:p,title:g,marginSize:x,imageSettings:m}=n,b=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:$,cells:z,numCells:w,calculatedImageSettings:y}=od({value:s,level:u,minVersion:l,boostLevel:p,includeMargin:h,marginSize:x,imageSettings:m,size:i});let k=z,C=null;m!=null&&y!=null&&(y.excavation!=null&&(k=rd(z,y.excavation)),C=a.createElement("image",{href:m.src,height:y.h,width:y.w,x:y.x+$,y:y.y+$,preserveAspectRatio:"none",opacity:y.opacity,crossOrigin:y.crossOrigin}));const _=td(k,$);return a.createElement("svg",vs({height:i,width:i,viewBox:`0 0 ${w} ${w}`,ref:o,role:"img"},b),!!g&&a.createElement("title",null,g),a.createElement("path",{fill:f,d:`M0,0 h${w}v${w}H0z`,shapeRendering:"crispEdges"}),a.createElement("path",{fill:c,d:_,shapeRendering:"crispEdges"}),C)});Ls.displayName="QRCodeSVG";const nd=a.createContext(void 0),Mt=()=>{const t=a.useContext(nd);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},U0=d.div`
3698
+ */var M0={L:vr.QrCode.Ecc.LOW,M:vr.QrCode.Ecc.MEDIUM,Q:vr.QrCode.Ecc.QUARTILE,H:vr.QrCode.Ecc.HIGH},Zl=128,Kl="L",Ql="#FFFFFF",Xl="#000000",Jl=!1,ed=1,O0=4,A0=0,L0=.1;function td(t,r=0){const o=[];return t.forEach(function(n,s){let a=null;n.forEach(function(p,f){if(!p&&a!==null){o.push(`M${a+r} ${s+r}h${f-a}v1H${a+r}z`),a=null;return}if(f===n.length-1){if(!p)return;a===null?o.push(`M${f+r},${s+r} h1v1H${f+r}z`):o.push(`M${a+r},${s+r} h${f+1-a}v1H${a+r}z`);return}p&&a===null&&(a=f)})}),o.join("")}function rd(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((s,a)=>a<r.x||a>=r.x+r.w?s:!1))}function D0(t,r,o,n){if(n==null)return null;const s=t.length+o*2,a=Math.floor(r*L0),p=s/r,f=(n.width||a)*p,c=(n.height||a)*p,h=n.x==null?t.length/2-f/2:n.x*p,l=n.y==null?t.length/2-c/2:n.y*p,u=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let x=Math.floor(h),w=Math.floor(l),$=Math.ceil(f+h-x),S=Math.ceil(c+l-w);g={x,y:w,w:$,h:S}}const v=n.crossOrigin;return{x:h,y:l,h:c,w:f,excavation:g,opacity:u,crossOrigin:v}}function N0(t,r){return r!=null?Math.max(Math.floor(r),0):t?O0:A0}function od({value:t,level:r,minVersion:o,includeMargin:n,marginSize:s,imageSettings:a,size:p,boostLevel:f}){let c=i.useMemo(()=>{const x=(Array.isArray(t)?t:[t]).reduce((w,$)=>(w.push(...vr.QrSegment.makeSegments($)),w),[]);return vr.QrCode.encodeSegments(x,M0[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:h,margin:l,numCells:u,calculatedImageSettings:g}=i.useMemo(()=>{let v=c.getModules();const x=N0(n,s),w=v.length+x*2,$=D0(v,p,x,a);return{cells:v,margin:x,numCells:w,calculatedImageSettings:$}},[c,p,a,n,s]);return{qrcode:c,margin:l,cells:h,numCells:u,calculatedImageSettings:g}}var F0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),B0=i.forwardRef(function(r,o){const n=r,{value:s,size:a=Zl,level:p=Kl,bgColor:f=Ql,fgColor:c=Xl,includeMargin:h=Jl,minVersion:l=ed,boostLevel:u,marginSize:g,imageSettings:v}=n,w=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:$}=w,S=bs(w,["style"]),k=v==null?void 0:v.src,P=i.useRef(null),E=i.useRef(null),z=i.useCallback(I=>{P.current=I,typeof o=="function"?o(I):o&&(o.current=I)},[o]),[y,m]=i.useState(!1),{margin:b,cells:_,numCells:j,calculatedImageSettings:T}=od({value:s,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:g,imageSettings:v,size:a});i.useEffect(()=>{if(P.current!=null){const I=P.current,M=I.getContext("2d");if(!M)return;let F=_;const L=E.current,B=T!=null&&L!==null&&L.complete&&L.naturalHeight!==0&&L.naturalWidth!==0;B&&T.excavation!=null&&(F=rd(_,T.excavation));const O=window.devicePixelRatio||1;I.height=I.width=a*O;const A=a/j*O;M.scale(A,A),M.fillStyle=f,M.fillRect(0,0,j,j),M.fillStyle=c,F0?M.fill(new Path2D(td(F,b))):_.forEach(function(X,te){X.forEach(function(V,q){V&&M.fillRect(q+b,te+b,1,1)})}),T&&(M.globalAlpha=T.opacity),B&&M.drawImage(L,T.x+b,T.y+b,T.w,T.h)}}),i.useEffect(()=>{m(!1)},[k]);const R=vs({height:a,width:a},$);let C=null;return k!=null&&(C=i.createElement("img",{src:k,key:k,style:{display:"none"},onLoad:()=>{m(!0)},ref:E,crossOrigin:T==null?void 0:T.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",vs({style:R,height:a,width:a,ref:z,role:"img"},S)),C)});B0.displayName="QRCodeCanvas";var Ls=i.forwardRef(function(r,o){const n=r,{value:s,size:a=Zl,level:p=Kl,bgColor:f=Ql,fgColor:c=Xl,includeMargin:h=Jl,minVersion:l=ed,boostLevel:u,title:g,marginSize:v,imageSettings:x}=n,w=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:$,cells:S,numCells:k,calculatedImageSettings:P}=od({value:s,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:v,imageSettings:x,size:a});let E=S,z=null;x!=null&&P!=null&&(P.excavation!=null&&(E=rd(S,P.excavation)),z=i.createElement("image",{href:x.src,height:P.h,width:P.w,x:P.x+$,y:P.y+$,preserveAspectRatio:"none",opacity:P.opacity,crossOrigin:P.crossOrigin}));const y=td(E,$);return i.createElement("svg",vs({height:a,width:a,viewBox:`0 0 ${k} ${k}`,ref:o,role:"img"},w),!!g&&i.createElement("title",null,g),i.createElement("path",{fill:f,d:`M0,0 h${k}v${k}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:y,shapeRendering:"crispEdges"}),z)});Ls.displayName="QRCodeSVG";const nd=i.createContext(void 0),Mt=()=>{const t=i.useContext(nd);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},U0=d.div`
3699
3699
  position: fixed;
3700
3700
  background: var(--color-background);
3701
3701
  border-radius: var(--radius-md);
@@ -3709,12 +3709,12 @@ cursor: pointer;
3709
3709
  @media (max-width: 600px) {
3710
3710
  width: calc(100vw - 48px);
3711
3711
  }
3712
- `,ma=d.div`
3712
+ `,mi=d.div`
3713
3713
  display: flex;
3714
3714
  gap: 8px;
3715
3715
  justify-content: flex-end;
3716
3716
  margin-top: 16px;
3717
- `,xa=d.div`
3717
+ `,xi=d.div`
3718
3718
  font-size: 14px;
3719
3719
  font-weight: 400;
3720
3720
  color: var(--color-foreground);
@@ -3734,7 +3734,7 @@ cursor: pointer;
3734
3734
  justify-content: center;
3735
3735
  color: var(--color-muted);
3736
3736
  flex-shrink: 0;
3737
- `,va=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:s,triggerRef:i})=>{const u=a.useRef(null),[f,c]=a.useState(!1),[h,l]=a.useState({top:0,left:0}),{toast:p}=Mt();a.useEffect(()=>{c(!0);const _=setTimeout(()=>{if(!u.current||!(i!=null&&i.current))return;const I=i.current;if(I){const S=I.getBoundingClientRect(),T=380,E=300,j=8;let R=0,M=0;const F=window.innerHeight-S.bottom,A=S.top;F>=E+j?(R=S.bottom+j,M=S.right-T,M<j&&(M=S.left,M+T>window.innerWidth-j&&(M=(window.innerWidth-T)/2))):A>=E+j?(R=S.top-E-j,M=S.right-T,M<j&&(M=S.left,M+T>window.innerWidth-j&&(M=(window.innerWidth-T)/2))):(R=S.bottom+j,M=S.right-T,M<j&&(M=S.left)),l({top:R,left:M})}},10),v=I=>{u.current&&!u.current.contains(I.target)&&t()},P=I=>{I.key==="Escape"&&t()};return document.addEventListener("mousedown",v),document.addEventListener("keydown",P),()=>{clearTimeout(_),document.removeEventListener("mousedown",v),document.removeEventListener("keydown",P)}},[t,i]);const[g,x]=a.useState(s?"otp":"email"),[m,b]=a.useState(s||""),[$,z]=a.useState(""),[w,y]=a.useState(!1),k=async()=>{if(!(!m||w)){y(!0);try{await r(m),x("otp")}catch(_){const v=_.message||"Failed to add email address. Please try again.";p(v,"error")}finally{y(!1)}}},C=async()=>{y(!0);try{await o($),t()}catch(_){const v=_.message||"Failed to verify email. Please check the code and try again.";p(v,"error")}finally{y(!1)}};return f?e.jsx(U0,{ref:u,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:g==="email"?e.jsxs(e.Fragment,{children:[e.jsx(xa,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(W0,{children:[e.jsx(V0,{children:e.jsx(on,{size:16})}),e.jsx(ce,{id:"email-input",type:"email",placeholder:"Email address",value:m,onChange:_=>b(_.target.value),style:{flex:1}})]})}),e.jsxs(ma,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:k,disabled:!m||w,style:{width:"auto",padding:"0 var(--space-md)"},children:w?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(xa,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",m]}),e.jsx(Tt,{onComplete:async _=>z(_),onResend:n,isSubmitting:w}),e.jsxs(ma,{children:[e.jsx(Q,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(Q,{onClick:C,disabled:$.length<6||w,style:{width:"auto",padding:"0 var(--space-md)"},children:w?"Verifying...":"Verify"})]})]})}):null},G0=d.div`
3737
+ `,vi=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:s,triggerRef:a})=>{const p=i.useRef(null),[f,c]=i.useState(!1),[h,l]=i.useState({top:0,left:0}),{toast:u}=Mt();i.useEffect(()=>{c(!0);const y=setTimeout(()=>{if(!p.current||!(a!=null&&a.current))return;const _=a.current;if(_){const j=_.getBoundingClientRect(),T=380,R=300,C=8;let I=0,M=0;const F=window.innerHeight-j.bottom,L=j.top;F>=R+C?(I=j.bottom+C,M=j.right-T,M<C&&(M=j.left,M+T>window.innerWidth-C&&(M=(window.innerWidth-T)/2))):L>=R+C?(I=j.top-R-C,M=j.right-T,M<C&&(M=j.left,M+T>window.innerWidth-C&&(M=(window.innerWidth-T)/2))):(I=j.bottom+C,M=j.right-T,M<C&&(M=j.left)),l({top:I,left:M})}},10),m=_=>{p.current&&!p.current.contains(_.target)&&t()},b=_=>{_.key==="Escape"&&t()};return document.addEventListener("mousedown",m),document.addEventListener("keydown",b),()=>{clearTimeout(y),document.removeEventListener("mousedown",m),document.removeEventListener("keydown",b)}},[t,a]);const[g,v]=i.useState(s?"otp":"email"),[x,w]=i.useState(s||""),[$,S]=i.useState(""),[k,P]=i.useState(!1),E=async()=>{if(!(!x||k)){P(!0);try{await r(x),v("otp")}catch(y){const m=y.message||"Failed to add email address. Please try again.";u(m,"error")}finally{P(!1)}}},z=async()=>{P(!0);try{await o($),t()}catch(y){const m=y.message||"Failed to verify email. Please check the code and try again.";u(m,"error")}finally{P(!1)}};return f?e.jsx(U0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),children:g==="email"?e.jsxs(e.Fragment,{children:[e.jsx(xi,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(W0,{children:[e.jsx(V0,{children:e.jsx(on,{size:16})}),e.jsx(le,{id:"email-input",type:"email",placeholder:"Email address",value:x,onChange:y=>w(y.target.value),style:{flex:1}})]})}),e.jsxs(mi,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:E,disabled:!x||k,style:{width:"auto",padding:"0 var(--space-md)"},children:k?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",x]}),e.jsx(Tt,{onComplete:async y=>S(y),onResend:n,isSubmitting:k}),e.jsxs(mi,{children:[e.jsx(Q,{$outline:!0,onClick:()=>v("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(Q,{onClick:z,disabled:$.length<6||k,style:{width:"auto",padding:"0 var(--space-md)"},children:k?"Verifying...":"Verify"})]})]})}):null},G0=d.div`
3738
3738
  position: fixed;
3739
3739
  background: var(--color-background);
3740
3740
  border-radius: var(--radius-md);
@@ -3748,17 +3748,17 @@ cursor: pointer;
3748
3748
  @media (max-width: 600px) {
3749
3749
  width: calc(100vw - 48px);
3750
3750
  }
3751
- `,ba=d.div`
3751
+ `,bi=d.div`
3752
3752
  display: flex;
3753
3753
  gap: 8px;
3754
3754
  justify-content: flex-end;
3755
3755
  margin-top: 16px;
3756
- `,ya=d.div`
3756
+ `,yi=d.div`
3757
3757
  font-size: 14px;
3758
3758
  font-weight: 400;
3759
3759
  color: var(--color-foreground);
3760
3760
  margin-bottom: 12px;
3761
- `,wa=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:s,triggerRef:i})=>{var P;const u=a.useRef(null),[f,c]=a.useState(!1),[h,l]=a.useState({top:0,left:0}),{toast:p}=Mt();a.useEffect(()=>{c(!0);const I=setTimeout(()=>{if(!u.current||!(i!=null&&i.current))return;const E=i.current;if(E){const j=E.getBoundingClientRect(),R=380,M=300,F=8;let A=0,B=0;const O=window.innerHeight-j.bottom,L=j.top;O>=M+F?(A=j.bottom+F,B=j.right-R,B<F&&(B=j.left,B+R>window.innerWidth-F&&(B=(window.innerWidth-R)/2))):L>=M+F?(A=j.top-M-F,B=j.right-R,B<F&&(B=j.left,B+R>window.innerWidth-F&&(B=(window.innerWidth-R)/2))):(A=j.bottom+F,B=j.right-R,B<F&&(B=j.left)),l({top:A,left:B})}},10),S=E=>{u.current&&!u.current.contains(E.target)&&t()},T=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",T),()=>{clearTimeout(I),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",T)}},[t,i]);const[g,x]=a.useState(n?"otp":"phone"),[m,b]=a.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[$,z]=a.useState((P=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:P.pop()),[w,y]=a.useState(""),[k,C]=a.useState(!1),_=async()=>{if(!(!m||k)){C(!0);try{await r(m,$||""),x("otp")}catch(I){const S=I.message||"Failed to add phone number. Please try again.";p(S,"error")}finally{C(!1)}}},v=async()=>{C(!0);try{await o(w),t()}catch(I){const S=I.message||"Failed to verify phone. Please check the code and try again.";p(S,"error")}finally{C(!1)}};return f?e.jsx(G0,{ref:u,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:I=>I.stopPropagation(),children:g==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(ya,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(qr,{value:m,onChange:I=>b(I.target.value),error:"",countryCode:$,setCountryCode:z})}),e.jsxs(ba,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:_,disabled:!m||k,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ya,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(Tt,{onComplete:I=>y(I),onResend:async()=>s()})}),e.jsxs(ba,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:v,disabled:w.length!==6||k,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},H0=d.div`
3761
+ `,wi=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:s,triggerRef:a})=>{var b;const p=i.useRef(null),[f,c]=i.useState(!1),[h,l]=i.useState({top:0,left:0}),{toast:u}=Mt();i.useEffect(()=>{c(!0);const _=setTimeout(()=>{if(!p.current||!(a!=null&&a.current))return;const R=a.current;if(R){const C=R.getBoundingClientRect(),I=380,M=300,F=8;let L=0,B=0;const O=window.innerHeight-C.bottom,A=C.top;O>=M+F?(L=C.bottom+F,B=C.right-I,B<F&&(B=C.left,B+I>window.innerWidth-F&&(B=(window.innerWidth-I)/2))):A>=M+F?(L=C.top-M-F,B=C.right-I,B<F&&(B=C.left,B+I>window.innerWidth-F&&(B=(window.innerWidth-I)/2))):(L=C.bottom+F,B=C.right-I,B<F&&(B=C.left)),l({top:L,left:B})}},10),j=R=>{p.current&&!p.current.contains(R.target)&&t()},T=R=>{R.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",T),()=>{clearTimeout(_),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",T)}},[t,a]);const[g,v]=i.useState(n?"otp":"phone"),[x,w]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[$,S]=i.useState((b=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:b.pop()),[k,P]=i.useState(""),[E,z]=i.useState(!1),y=async()=>{if(!(!x||E)){z(!0);try{await r(x,$||""),v("otp")}catch(_){const j=_.message||"Failed to add phone number. Please try again.";u(j,"error")}finally{z(!1)}}},m=async()=>{z(!0);try{await o(k),t()}catch(_){const j=_.message||"Failed to verify phone. Please check the code and try again.";u(j,"error")}finally{z(!1)}};return f?e.jsx(G0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:g==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(qr,{value:x,onChange:_=>w(_.target.value),error:"",countryCode:$,setCountryCode:S})}),e.jsxs(bi,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:y,disabled:!x||E,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(yi,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(Tt,{onComplete:_=>P(_),onResend:async()=>s()})}),e.jsxs(bi,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:m,disabled:k.length!==6||E,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},H0=d.div`
3762
3762
  position: fixed;
3763
3763
  background: var(--color-background);
3764
3764
  border-radius: var(--radius-md);
@@ -3791,17 +3791,17 @@ cursor: pointer;
3791
3791
  opacity: 0.5;
3792
3792
  cursor: not-allowed;
3793
3793
  }
3794
- `,ja=d.div`
3794
+ `,ji=d.div`
3795
3795
  display: flex;
3796
3796
  gap: 8px;
3797
3797
  justify-content: flex-end;
3798
3798
  margin-top: 16px;
3799
- `,_a=d.div`
3799
+ `,_i=d.div`
3800
3800
  font-size: 14px;
3801
3801
  font-weight: 400;
3802
3802
  color: var(--color-foreground);
3803
3803
  margin-bottom: 8px;
3804
- `,q0=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const s=a.useRef(null),[i,u]=a.useState("qr"),[f,c]=a.useState(""),[h,l]=a.useState(""),[p,g]=a.useState(["",""]),[x,m]=a.useState(!1),[b,$]=a.useState(!1),[z,w]=a.useState({top:0,left:0}),{toast:y}=Mt();a.useEffect(()=>{$(!0);const C=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const P=n.current;if(P){const I=P.getBoundingClientRect(),S=380,T=400,E=8;let j=0,R=0;const M=window.innerHeight-I.bottom,F=I.top;M>=T+E?(j=I.bottom+E,R=I.right-S,R<E&&(R=I.left,R+S>window.innerWidth-E&&(R=(window.innerWidth-S)/2))):F>=T+E?(j=I.top-T-E,R=I.right-S,R<E&&(R=I.left,R+S>window.innerWidth-E&&(R=(window.innerWidth-S)/2))):(j=I.bottom+E,R=I.right-S,R<E&&(R=I.left)),w({top:j,left:R})}},10),_=P=>{s.current&&!s.current.contains(P.target)&&t()},v=P=>{P.key==="Escape"&&t()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",v),()=>{clearTimeout(C),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",v)}},[t,n]),a.useEffect(()=>{(async()=>{m(!0);try{const _=await r();c(_.otp_url||""),l(_.totp_secret||"")}catch(_){const v=_.message||"Failed to setup two-factor authentication. Please try again.";y(v,"error")}finally{m(!1)}})()},[]);const k=async()=>{if(!p.some(C=>C.length!==6)){m(!0);try{await o(p),t()}catch(C){const _=C.message||"Failed to verify codes. Please check your authenticator app and try again.";y(_,"error")}finally{m(!1)}}};return b?e.jsx(H0,{ref:s,style:{top:`${z.top}px`,left:`${z.left}px`,visibility:z.top>0?"visible":"hidden"},onClick:C=>C.stopPropagation(),children:i==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(_a,{children:"Setup Two-Factor Authentication"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:x?e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)"},children:"Loading..."}):f?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Ls,{value:f,size:150,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)",color:"var(--color-error)"},children:"QR Code Not Available"})}),h&&e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",marginBottom:"16px",fontSize:"12px"},children:[e.jsx("div",{style:{color:"var(--color-secondary-text)",marginBottom:"4px"},children:"Or enter manually:"}),e.jsx("code",{style:{fontFamily:"monospace",wordBreak:"break-all",color:"var(--color-secondary-text)"},children:h})]}),e.jsx(ja,{children:e.jsx(Gn,{$primary:!0,onClick:()=>u("verify"),disabled:x||!f,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(_a,{children:"Verify Your Authenticator"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Enter two consecutive codes from your authenticator app"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:[e.jsx(ce,{id:"totp-code-1",type:"text",placeholder:"000000",value:p[0],onChange:C=>{const _=C.target.value.replace(/[^0-9]/g,"").substring(0,6);g([_,p[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(ce,{id:"totp-code-2",type:"text",placeholder:"000000",value:p[1],onChange:C=>{const _=C.target.value.replace(/[^0-9]/g,"").substring(0,6);g([p[0],_])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(ja,{children:[e.jsx(Gn,{onClick:()=>u("qr"),children:"Back"}),e.jsx(Gn,{$primary:!0,onClick:k,disabled:x||p.some(C=>C.length!==6),children:x?"Verifying...":"Verify"})]})]})}):null},Y0=d.div`
3804
+ `,q0=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const s=i.useRef(null),[a,p]=i.useState("qr"),[f,c]=i.useState(""),[h,l]=i.useState(""),[u,g]=i.useState(["",""]),[v,x]=i.useState(!1),[w,$]=i.useState(!1),[S,k]=i.useState({top:0,left:0}),{toast:P}=Mt();i.useEffect(()=>{$(!0);const z=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const b=n.current;if(b){const _=b.getBoundingClientRect(),j=380,T=400,R=8;let C=0,I=0;const M=window.innerHeight-_.bottom,F=_.top;M>=T+R?(C=_.bottom+R,I=_.right-j,I<R&&(I=_.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):F>=T+R?(C=_.top-T-R,I=_.right-j,I<R&&(I=_.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(C=_.bottom+R,I=_.right-j,I<R&&(I=_.left)),k({top:C,left:I})}},10),y=b=>{s.current&&!s.current.contains(b.target)&&t()},m=b=>{b.key==="Escape"&&t()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",m),()=>{clearTimeout(z),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",m)}},[t,n]),i.useEffect(()=>{(async()=>{x(!0);try{const y=await r();c(y.otp_url||""),l(y.totp_secret||"")}catch(y){const m=y.message||"Failed to setup two-factor authentication. Please try again.";P(m,"error")}finally{x(!1)}})()},[]);const E=async()=>{if(!u.some(z=>z.length!==6)){x(!0);try{await o(u),t()}catch(z){const y=z.message||"Failed to verify codes. Please check your authenticator app and try again.";P(y,"error")}finally{x(!1)}}};return w?e.jsx(H0,{ref:s,style:{top:`${S.top}px`,left:`${S.left}px`,visibility:S.top>0?"visible":"hidden"},onClick:z=>z.stopPropagation(),children:a==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(_i,{children:"Setup Two-Factor Authentication"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:v?e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)"},children:"Loading..."}):f?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Ls,{value:f,size:150,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)",color:"var(--color-error)"},children:"QR Code Not Available"})}),h&&e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",marginBottom:"16px",fontSize:"12px"},children:[e.jsx("div",{style:{color:"var(--color-secondary-text)",marginBottom:"4px"},children:"Or enter manually:"}),e.jsx("code",{style:{fontFamily:"monospace",wordBreak:"break-all",color:"var(--color-secondary-text)"},children:h})]}),e.jsx(ji,{children:e.jsx(Gn,{$primary:!0,onClick:()=>p("verify"),disabled:v||!f,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(_i,{children:"Verify Your Authenticator"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Enter two consecutive codes from your authenticator app"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:[e.jsx(le,{id:"totp-code-1",type:"text",placeholder:"000000",value:u[0],onChange:z=>{const y=z.target.value.replace(/[^0-9]/g,"").substring(0,6);g([y,u[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(le,{id:"totp-code-2",type:"text",placeholder:"000000",value:u[1],onChange:z=>{const y=z.target.value.replace(/[^0-9]/g,"").substring(0,6);g([u[0],y])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(ji,{children:[e.jsx(Gn,{onClick:()=>p("qr"),children:"Back"}),e.jsx(Gn,{$primary:!0,onClick:E,disabled:v||u.some(z=>z.length!==6),children:v?"Verifying...":"Verify"})]})]})}):null},Y0=d.div`
3805
3805
  position: fixed;
3806
3806
  background: var(--color-background);
3807
3807
  border-radius: var(--radius-md);
@@ -3815,7 +3815,7 @@ cursor: pointer;
3815
3815
  @media (max-width: 600px) {
3816
3816
  width: calc(100vw - 48px);
3817
3817
  }
3818
- `,ka=d.button`
3818
+ `,ki=d.button`
3819
3819
  padding: 8px 16px;
3820
3820
  background: ${t=>t.$primary?"var(--color-primary)":"var(--color-background)"};
3821
3821
  color: ${t=>t.$primary?"white":"var(--color-secondary-text)"};
@@ -3871,7 +3871,7 @@ cursor: pointer;
3871
3871
  color: var(--color-error);
3872
3872
  font-size: 12px;
3873
3873
  margin-top: 4px;
3874
- `,Ca=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const s=a.useRef(null),[i,u]=a.useState(!1),[f,c]=a.useState({top:0,left:0}),[h,l]=a.useState(""),[p,g]=a.useState(""),[x,m]=a.useState(""),[b,$]=a.useState(!1),[z,w]=a.useState(!1),[y,k]=a.useState(!1),[C,_]=a.useState(!1),[v,P]=a.useState({});a.useEffect(()=>{u(!0);const S=setTimeout(()=>{if(!s.current||!(o!=null&&o.current))return;const j=o.current;if(j){const R=j.getBoundingClientRect(),M=380,F=350,A=8;let B=0,O=0;const L=window.innerHeight-R.bottom,X=R.top;L>=F+A?(B=R.bottom+A,O=R.right-M,O<A&&(O=R.left,O+M>window.innerWidth-A&&(O=(window.innerWidth-M)/2))):X>=F+A?(B=R.top-F-A,O=R.right-M,O<A&&(O=R.left,O+M>window.innerWidth-A&&(O=(window.innerWidth-M)/2))):(B=R.bottom+A,O=R.right-M,O<A&&(O=R.left)),c({top:B,left:O})}},10),T=j=>{s.current&&!s.current.contains(j.target)&&t()},E=j=>{j.key==="Escape"&&t()};return document.addEventListener("mousedown",T),document.addEventListener("keydown",E),()=>{clearTimeout(S),document.removeEventListener("mousedown",T),document.removeEventListener("keydown",E)}},[t,o]);const I=async()=>{if(C)return;const S={};if(!n&&!h&&(S.currentPassword="Current password is required"),p?p.length<8&&(S.newPassword="Password must be at least 8 characters"):S.newPassword="New password is required",p!==x&&(S.confirmPassword="Passwords do not match"),Object.keys(S).length>0){P(S);return}_(!0);try{await r(n?"":h,p),t()}catch(T){P({form:T.message||"Failed to update password"})}finally{_(!1)}};return i?e.jsxs(Y0,{ref:s,style:{top:`${f.top}px`,left:`${f.left}px`,visibility:f.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),children:[e.jsx(K0,{children:n?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&e.jsxs(Hn,{children:[e.jsx(ae,{children:"Current Password"}),e.jsxs(qn,{children:[e.jsx(ce,{type:b?"text":"password",placeholder:"Enter your current password",value:h,onChange:S=>l(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>$(!b),"aria-label":b?"Hide current password":"Show current password",children:b?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),v.currentPassword&&e.jsx(zo,{children:v.currentPassword})]}),e.jsxs(Hn,{children:[e.jsx(ae,{children:n?"Password":"New Password"}),e.jsxs(qn,{children:[e.jsx(ce,{type:z?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:p,onChange:S=>g(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>w(!z),"aria-label":z?"Hide new password":"Show new password",children:z?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),v.newPassword&&e.jsx(zo,{children:v.newPassword})]}),e.jsxs(Hn,{children:[e.jsx(ae,{children:"Confirm New Password"}),e.jsxs(qn,{children:[e.jsx(ce,{type:y?"text":"password",placeholder:"Confirm your new password",value:x,onChange:S=>m(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>k(!y),"aria-label":y?"Hide confirm password":"Show confirm password",children:y?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),v.confirmPassword&&e.jsx(zo,{children:v.confirmPassword})]}),v.form&&e.jsx(zo,{children:v.form}),e.jsxs(Z0,{children:[e.jsx(ka,{onClick:t,children:"Cancel"}),e.jsx(ka,{$primary:!0,onClick:I,disabled:C,children:C?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},Q0=d.div`
3874
+ `,Ci=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const s=i.useRef(null),[a,p]=i.useState(!1),[f,c]=i.useState({top:0,left:0}),[h,l]=i.useState(""),[u,g]=i.useState(""),[v,x]=i.useState(""),[w,$]=i.useState(!1),[S,k]=i.useState(!1),[P,E]=i.useState(!1),[z,y]=i.useState(!1),[m,b]=i.useState({});i.useEffect(()=>{p(!0);const j=setTimeout(()=>{if(!s.current||!(o!=null&&o.current))return;const C=o.current;if(C){const I=C.getBoundingClientRect(),M=380,F=350,L=8;let B=0,O=0;const A=window.innerHeight-I.bottom,X=I.top;A>=F+L?(B=I.bottom+L,O=I.right-M,O<L&&(O=I.left,O+M>window.innerWidth-L&&(O=(window.innerWidth-M)/2))):X>=F+L?(B=I.top-F-L,O=I.right-M,O<L&&(O=I.left,O+M>window.innerWidth-L&&(O=(window.innerWidth-M)/2))):(B=I.bottom+L,O=I.right-M,O<L&&(O=I.left)),c({top:B,left:O})}},10),T=C=>{s.current&&!s.current.contains(C.target)&&t()},R=C=>{C.key==="Escape"&&t()};return document.addEventListener("mousedown",T),document.addEventListener("keydown",R),()=>{clearTimeout(j),document.removeEventListener("mousedown",T),document.removeEventListener("keydown",R)}},[t,o]);const _=async()=>{if(z)return;const j={};if(!n&&!h&&(j.currentPassword="Current password is required"),u?u.length<8&&(j.newPassword="Password must be at least 8 characters"):j.newPassword="New password is required",u!==v&&(j.confirmPassword="Passwords do not match"),Object.keys(j).length>0){b(j);return}y(!0);try{await r(n?"":h,u),t()}catch(T){b({form:T.message||"Failed to update password"})}finally{y(!1)}};return a?e.jsxs(Y0,{ref:s,style:{top:`${f.top}px`,left:`${f.left}px`,visibility:f.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:[e.jsx(K0,{children:n?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&e.jsxs(Hn,{children:[e.jsx(ce,{children:"Current Password"}),e.jsxs(qn,{children:[e.jsx(le,{type:w?"text":"password",placeholder:"Enter your current password",value:h,onChange:j=>l(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>$(!w),"aria-label":w?"Hide current password":"Show current password",children:w?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),m.currentPassword&&e.jsx(zo,{children:m.currentPassword})]}),e.jsxs(Hn,{children:[e.jsx(ce,{children:n?"Password":"New Password"}),e.jsxs(qn,{children:[e.jsx(le,{type:S?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:u,onChange:j=>g(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>k(!S),"aria-label":S?"Hide new password":"Show new password",children:S?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),m.newPassword&&e.jsx(zo,{children:m.newPassword})]}),e.jsxs(Hn,{children:[e.jsx(ce,{children:"Confirm New Password"}),e.jsxs(qn,{children:[e.jsx(le,{type:P?"text":"password",placeholder:"Confirm your new password",value:v,onChange:j=>x(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>E(!P),"aria-label":P?"Hide confirm password":"Show confirm password",children:P?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),m.confirmPassword&&e.jsx(zo,{children:m.confirmPassword})]}),m.form&&e.jsx(zo,{children:m.form}),e.jsxs(Z0,{children:[e.jsx(ki,{onClick:t,children:"Cancel"}),e.jsx(ki,{$primary:!0,onClick:_,disabled:z,children:z?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},Q0=d.div`
3875
3875
  position: fixed;
3876
3876
  background: var(--color-background);
3877
3877
  border-radius: var(--radius-md);
@@ -3909,7 +3909,7 @@ cursor: pointer;
3909
3909
  color: var(--color-warning-text, var(--color-foreground));
3910
3910
  margin: 0;
3911
3911
  line-height: 1.5;
3912
- `,rv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=a.useRef(null),[s,i]=a.useState(!1),[u,f]=a.useState({top:0,left:0}),[c,h]=a.useState(""),[l,p]=a.useState(!1),{toast:g}=Mt();a.useEffect(()=>{i(!0);const m=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const z=o.current;if(z){const w=z.getBoundingClientRect(),y=400,k=300,C=8;let _=0,v=0;const P=window.innerHeight-w.bottom,I=w.top;P>=k+C?(_=w.bottom+C,v=w.right-y,v<C&&(v=w.left,v+y>window.innerWidth-C&&(v=(window.innerWidth-y)/2))):I>=k+C?(_=w.top-k-C,v=w.right-y,v<C&&(v=w.left,v+y>window.innerWidth-C&&(v=(window.innerWidth-y)/2))):(_=w.bottom+C,v=w.right-y,v<C&&(v=w.left)),f({top:_,left:v})}},10),b=z=>{n.current&&!n.current.contains(z.target)&&t()},$=z=>{z.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",$),()=>{clearTimeout(m),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",$)}},[t,o]);const x=async()=>{if(!(!c||l)){p(!0);try{await r(c),t()}catch(m){const b=m.message||"Failed to remove password. Please try again.";g(b,"error")}finally{p(!1)}}};return s?e.jsxs(Q0,{ref:n,style:{top:`${u.top}px`,left:`${u.left}px`,visibility:u.top>0?"visible":"hidden"},onClick:m=>m.stopPropagation(),children:[e.jsxs(J0,{children:[e.jsx(ut,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(ev,{children:e.jsx(tv,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(ce,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:m=>h(m.target.value),autoFocus:!0})]}),e.jsxs(X0,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:x,disabled:!c||l,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:l?"Removing...":"Remove Password"})]})]}):null},ov=d.div`
3912
+ `,rv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(!1),[p,f]=i.useState({top:0,left:0}),[c,h]=i.useState(""),[l,u]=i.useState(!1),{toast:g}=Mt();i.useEffect(()=>{a(!0);const x=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const S=o.current;if(S){const k=S.getBoundingClientRect(),P=400,E=300,z=8;let y=0,m=0;const b=window.innerHeight-k.bottom,_=k.top;b>=E+z?(y=k.bottom+z,m=k.right-P,m<z&&(m=k.left,m+P>window.innerWidth-z&&(m=(window.innerWidth-P)/2))):_>=E+z?(y=k.top-E-z,m=k.right-P,m<z&&(m=k.left,m+P>window.innerWidth-z&&(m=(window.innerWidth-P)/2))):(y=k.bottom+z,m=k.right-P,m<z&&(m=k.left)),f({top:y,left:m})}},10),w=S=>{n.current&&!n.current.contains(S.target)&&t()},$=S=>{S.key==="Escape"&&t()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",$),()=>{clearTimeout(x),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",$)}},[t,o]);const v=async()=>{if(!(!c||l)){u(!0);try{await r(c),t()}catch(x){const w=x.message||"Failed to remove password. Please try again.";g(w,"error")}finally{u(!1)}}};return s?e.jsxs(Q0,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:x=>x.stopPropagation(),children:[e.jsxs(J0,{children:[e.jsx(ut,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(ev,{children:e.jsx(tv,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(le,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:x=>h(x.target.value),autoFocus:!0})]}),e.jsxs(X0,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:v,disabled:!c||l,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:l?"Removing...":"Remove Password"})]})]}):null},ov=d.div`
3913
3913
  position: fixed;
3914
3914
  background: var(--color-background);
3915
3915
  border-radius: var(--radius-md);
@@ -3923,7 +3923,7 @@ cursor: pointer;
3923
3923
  @media (max-width: 600px) {
3924
3924
  width: calc(100vw - 48px);
3925
3925
  }
3926
- `,Sa=d.button`
3926
+ `,Si=d.button`
3927
3927
  padding: 8px 16px;
3928
3928
  background: ${t=>t.$primary?"var(--color-primary)":"var(--color-background)"};
3929
3929
  color: ${t=>t.$primary?"white":"var(--color-secondary-text)"};
@@ -3951,10 +3951,10 @@ cursor: pointer;
3951
3951
  font-size: 14px;
3952
3952
  font-weight: 400;
3953
3953
  color: var(--color-foreground);
3954
- `,iv=d.div`
3954
+ `,av=d.div`
3955
3955
  display: flex;
3956
3956
  gap: 8px;
3957
- `,av=d.div`
3957
+ `,iv=d.div`
3958
3958
  display: grid;
3959
3959
  grid-template-columns: repeat(2, 1fr);
3960
3960
  gap: 6px;
@@ -3975,7 +3975,7 @@ cursor: pointer;
3975
3975
  background: var(--color-input-background-hover);
3976
3976
  border-color: var(--color-primary);
3977
3977
  }
3978
- `,lv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:s})=>{const i=a.useRef(null),[u,f]=a.useState(!1),[c,h]=a.useState({top:0,left:0});return a.useEffect(()=>{f(!0);const l=setTimeout(()=>{if(!i.current||!(s!=null&&s.current))return;const x=s.current;if(x){const m=x.getBoundingClientRect(),b=380,$=300,z=8;let w=0,y=0;const k=window.innerHeight-m.bottom,C=m.top;k>=$+z?(w=m.bottom+z,y=m.right-b,y<z&&(y=m.left,y+b>window.innerWidth-z&&(y=(window.innerWidth-b)/2))):C>=$+z?(w=m.top-$-z,y=m.right-b,y<z&&(y=m.left,y+b>window.innerWidth-z&&(y=(window.innerWidth-b)/2))):(w=m.bottom+z,y=m.right-b,y<z&&(y=m.left)),h({top:w,left:y})}},10),p=x=>{i.current&&!i.current.contains(x.target)&&r()},g=x=>{x.key==="Escape"&&r()};return document.addEventListener("mousedown",p),document.addEventListener("keydown",g),()=>{clearTimeout(l),document.removeEventListener("mousedown",p),document.removeEventListener("keydown",g)}},[r,s]),u?e.jsxs(ov,{ref:i,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:l=>l.stopPropagation(),children:[e.jsxs(nv,{children:[e.jsx(sv,{children:"Backup Codes"}),e.jsxs(iv,{children:[e.jsxs(Sa,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Jt,{size:14}),"Copy"]}),e.jsxs(Sa,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(rn,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(av,{children:t.map((l,p)=>e.jsx(cv,{onClick:()=>{navigator.clipboard.writeText(l)},title:"Click to copy",children:l},p))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},dv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:48,height:48,...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),uv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),pv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),hv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),fv=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),gv=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),mv=ir`
3978
+ `,lv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:s})=>{const a=i.useRef(null),[p,f]=i.useState(!1),[c,h]=i.useState({top:0,left:0});return i.useEffect(()=>{f(!0);const l=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const v=s.current;if(v){const x=v.getBoundingClientRect(),w=380,$=300,S=8;let k=0,P=0;const E=window.innerHeight-x.bottom,z=x.top;E>=$+S?(k=x.bottom+S,P=x.right-w,P<S&&(P=x.left,P+w>window.innerWidth-S&&(P=(window.innerWidth-w)/2))):z>=$+S?(k=x.top-$-S,P=x.right-w,P<S&&(P=x.left,P+w>window.innerWidth-S&&(P=(window.innerWidth-w)/2))):(k=x.bottom+S,P=x.right-w,P<S&&(P=x.left)),h({top:k,left:P})}},10),u=v=>{a.current&&!a.current.contains(v.target)&&r()},g=v=>{v.key==="Escape"&&r()};return document.addEventListener("mousedown",u),document.addEventListener("keydown",g),()=>{clearTimeout(l),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",g)}},[r,s]),p?e.jsxs(ov,{ref:a,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:l=>l.stopPropagation(),children:[e.jsxs(nv,{children:[e.jsx(sv,{children:"Backup Codes"}),e.jsxs(av,{children:[e.jsxs(Si,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Jt,{size:14}),"Copy"]}),e.jsxs(Si,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(rn,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(iv,{children:t.map((l,u)=>e.jsx(cv,{onClick:()=>{navigator.clipboard.writeText(l)},title:"Click to copy",children:l},u))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},dv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:48,height:48,...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),uv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),pv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),hv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),fv=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),gv=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),mv=ar`
3979
3979
  0% { transform: rotate(0deg); }
3980
3980
  100% { transform: rotate(360deg); }
3981
3981
  `,xv=d.div`
@@ -3996,7 +3996,7 @@ cursor: pointer;
3996
3996
  transform: translateY(0);
3997
3997
  }
3998
3998
  }
3999
- `,za=d.div`
3999
+ `,zi=d.div`
4000
4000
  width: 100%;
4001
4001
  height: 600px;
4002
4002
  background: var(--color-background);
@@ -4110,7 +4110,7 @@ cursor: pointer;
4110
4110
  flex-wrap: wrap;
4111
4111
  gap: 12px;
4112
4112
  margin-bottom: 0;
4113
- `,wv=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),jv=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(dv,{...o}):r.includes("firefox")?e.jsx(uv,{...o}):r.includes("safari")?e.jsx(pv,{...o}):r.includes("edge")?e.jsx(hv,{...o}):r.includes("opera")?e.jsx(fv,{...o}):r.includes("brave")?e.jsx(gv,{...o}):e.jsx(wv,{})},_v=()=>{const[t,r]=a.useState(null),{signins:o,removeSignin:n,refetch:s,loading:i}=bc(),{refetch:u}=Ue(),{toast:f}=Mt(),c=o,h=async p=>{try{await n(p),await Promise.all([s(),u()]),r(null),f("Session ended successfully","info")}catch(g){f(g.message||"Failed to end session. Please try again.","error")}},l=p=>{if(!p||p.trim()==="")return"Unknown";const g=new Date(p);if(isNaN(g.getTime()))return"Unknown";const m=Math.floor((new Date().getTime()-g.getTime())/(1e3*60));return m<1?"Just now":m<60?`${m}m ago`:m<1440?`${Math.floor(m/60)}h ago`:g.toLocaleDateString()};return i?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:c&&c.length>0?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Browser & Device"}),e.jsx(Ce,{children:"Location"}),e.jsx(Ce,{children:"Last Active"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:c.map(p=>e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(sd,{children:e.jsx(jv,{browser:p.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:p.browser||"Unknown Browser"}),p.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.device})]})]})}),e.jsx(Me,{children:e.jsxs("div",{children:[e.jsx("div",{children:p.city&&p.country?`${p.city}, ${p.country}`:"Unknown location"}),p.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:p.ip_address})]})}),e.jsx(Me,{children:l(p.last_active_at)}),e.jsx(mt,{children:e.jsxs(nt,{open:t===p.id,openChange:g=>r(g?p.id:null),children:[e.jsx(it,{children:e.jsx(cn,{children:"•••"})}),e.jsx(st,{children:e.jsx(Te,{onClick:()=>h(p.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(It,{size:14}),"End Session"]})})})]})})]},p.id))})]}):e.jsx(at,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},kv=()=>{var _,v,P,I;const{deployment:t}=ve(),{toast:r}=Mt(),[o,n]=a.useState(null),[s,i]=a.useState(""),[u,f]=a.useState(!1),[c,h]=a.useState(null),[l,p]=a.useState(""),g=a.useRef(null),x=a.useRef({}),{user:m,createEmailAddress:b,deleteEmailAddress:$,prepareEmailVerification:z,attemptEmailVerification:w,makeEmailPrimary:y}=sr();if(!((v=(_=t==null?void 0:t.auth_settings)==null?void 0:_.email_address)!=null&&v.enabled))return null;const k=async S=>{try{if(S===(m==null?void 0:m.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await $(S),m.refetch(),r("Email address deleted successfully","info")}catch(T){r(T.message||"Failed to delete email address. Please try again.","error")}},C=a.useMemo(()=>m!=null&&m.user_email_addresses?l.trim()?m.user_email_addresses.filter(S=>S.email.toLowerCase().includes(l.toLowerCase())):m.user_email_addresses:[],[m==null?void 0:m.user_email_addresses,l]);return e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{style:{marginBottom:"20px"},children:[e.jsx(zt,{value:l,onChange:p,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:g,onClick:()=>f(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),u&&e.jsx(va,{triggerRef:g,onClose:()=>f(!1),onAddEmail:async S=>{const T=await b(S);i(T.data.id),await z(T.data.id),m.refetch()},onPrepareVerification:async()=>{await z(s),m.refetch()},onAttemptVerification:async S=>{await w(s,S),m.refetch(),f(!1),i(""),r("Email added and verified successfully!","info")}})]})]}),C!=null&&C.length?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email Address"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:C.map(S=>e.jsxs(Ne,{children:[e.jsx(Me,{children:S.email}),e.jsx(Me,{children:S.id===(m==null?void 0:m.primary_email_address_id)?"Primary":S.verified?"Verified":"Not Verified"}),e.jsx(mt,{children:S.id!==(m==null?void 0:m.primary_email_address_id)||!S.verified?e.jsxs(nt,{open:o===S.id,openChange:T=>n(T?S.id:null),children:[e.jsx(it,{children:e.jsx(cn,{ref:T=>{T&&(x.current[S.id]=T)},children:"•••"})}),e.jsxs(st,{children:[S.id!==(m==null?void 0:m.primary_email_address_id)&&S.verified&&e.jsx(Te,{onClick:async()=>{try{await y(S.id),m.refetch(),n(null),r("Primary email updated successfully","info")}catch(T){r(T.message||"Failed to update primary email","error")}},children:"Make primary"}),!S.verified&&e.jsx(Te,{onClick:async()=>{n(null),await z(S.id),h(S.id)},children:"Verify email"}),S.id!==(m==null?void 0:m.primary_email_address_id)&&e.jsx(Te,{$destructive:!0,onClick:()=>{k(S.id),n(null)},children:"Remove"})]})]}):null})]},S.id))})]}):e.jsx(at,{title:l?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(va,{existingEmail:(I=(P=m==null?void 0:m.user_email_addresses)==null?void 0:P.find(S=>S.id===c))==null?void 0:I.email,triggerRef:{current:x.current[c]},onClose:()=>h(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await z(c),m.refetch()},onAttemptVerification:async S=>{await w(c,S),m.refetch(),h(null),r("Email verified successfully!","info")}})]})},Cv=()=>{var C,_,v,P;const{deployment:t}=ve(),[r,o]=a.useState(null),[n,s]=a.useState(""),[i,u]=a.useState(!1),[f,c]=a.useState(null),[h,l]=a.useState(""),p=a.useRef(null),g=a.useRef({}),{user:x,createPhoneNumber:m,deletePhoneNumber:b,preparePhoneVerification:$,attemptPhoneVerification:z,makePhonePrimary:w}=sr();if(!((_=(C=t==null?void 0:t.auth_settings)==null?void 0:C.phone_number)!=null&&_.enabled))return null;const y=I=>{const S=Oo.find(T=>T.dialCode===I);return(S==null?void 0:S.flag)||"🌍"},k=a.useMemo(()=>x!=null&&x.user_phone_numbers?h.trim()?x.user_phone_numbers.filter(I=>I.phone_number.toLowerCase().includes(h.toLowerCase())):x.user_phone_numbers:[],[x==null?void 0:x.user_phone_numbers,h]);return e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{style:{marginBottom:"20px"},children:[e.jsx(zt,{value:h,onChange:l,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:p,onClick:()=>u(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),i&&e.jsx(wa,{triggerRef:p,onClose:()=>u(!1),onAddPhone:async(I,S)=>{const T=await m(I,S);s(T.data.id),await $(T.data.id)},onPrepareVerification:async()=>{await $(n),x.refetch()},onAttemptVerification:async I=>{await z(n,I),x.refetch(),u(!1)}}),f&&e.jsx(wa,{existingPhone:(P=(v=x==null?void 0:x.user_phone_numbers)==null?void 0:v.find(I=>I.id===f))==null?void 0:P.phone_number,triggerRef:{current:g.current[f]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await $(f),x.refetch()},onAttemptVerification:async I=>{await z(f,I),x.refetch(),c(null)}})]})]}),k!=null&&k.length?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Phone Number"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:k.map(I=>e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:y(I.country_code)}),e.jsx("span",{children:I.country_code}),e.jsx("span",{children:I.phone_number})]})}),e.jsx(Me,{children:I.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":I.verified?"Verified":"Not Verified"}),e.jsx(mt,{children:e.jsxs(nt,{open:r===I.id,openChange:S=>o(S?I.id:null),children:[e.jsx(it,{children:e.jsx(cn,{ref:S=>{S&&(g.current[I.id]=S)},children:"•••"})}),e.jsxs(st,{children:[I.id!==(x==null?void 0:x.primary_phone_number_id)&&I.verified&&e.jsx(Te,{onClick:async()=>{await w(I.id),o(null),x.refetch()},children:"Make primary"}),!I.verified&&e.jsx(Te,{onClick:async()=>{await $(I.id),c(I.id),o(null)},children:"Verify phone"}),e.jsx(Te,{$destructive:!0,onClick:async()=>{await b(I.id),o(null),x.refetch()},children:"Remove"})]})]})})]},I.id))})]}):e.jsx(at,{title:h?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},sd=d.div`
4113
+ `,wv=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),jv=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(dv,{...o}):r.includes("firefox")?e.jsx(uv,{...o}):r.includes("safari")?e.jsx(pv,{...o}):r.includes("edge")?e.jsx(hv,{...o}):r.includes("opera")?e.jsx(fv,{...o}):r.includes("brave")?e.jsx(gv,{...o}):e.jsx(wv,{})},_v=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:s,loading:a}=bc(),{refetch:p}=Ue(),{toast:f}=Mt(),c=o,h=async u=>{try{await n(u),await Promise.all([s(),p()]),r(null),f("Session ended successfully","info")}catch(g){f(g.message||"Failed to end session. Please try again.","error")}},l=u=>{if(!u||u.trim()==="")return"Unknown";const g=new Date(u);if(isNaN(g.getTime()))return"Unknown";const x=Math.floor((new Date().getTime()-g.getTime())/(1e3*60));return x<1?"Just now":x<60?`${x}m ago`:x<1440?`${Math.floor(x/60)}h ago`:g.toLocaleDateString()};return a?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:c&&c.length>0?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Browser & Device"}),e.jsx(Ce,{children:"Location"}),e.jsx(Ce,{children:"Last Active"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:c.map(u=>e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(sd,{children:e.jsx(jv,{browser:u.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:u.browser||"Unknown Browser"}),u.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.device})]})]})}),e.jsx(Me,{children:e.jsxs("div",{children:[e.jsx("div",{children:u.city&&u.country?`${u.city}, ${u.country}`:"Unknown location"}),u.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.ip_address})]})}),e.jsx(Me,{children:l(u.last_active_at)}),e.jsx(mt,{children:e.jsxs(nt,{open:t===u.id,openChange:g=>r(g?u.id:null),children:[e.jsx(at,{children:e.jsx(cn,{children:"•••"})}),e.jsx(st,{children:e.jsx(Te,{onClick:()=>h(u.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Et,{size:14}),"End Session"]})})})]})})]},u.id))})]}):e.jsx(it,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},kv=()=>{var y,m,b,_;const{deployment:t}=ve(),{toast:r}=Mt(),[o,n]=i.useState(null),[s,a]=i.useState(""),[p,f]=i.useState(!1),[c,h]=i.useState(null),[l,u]=i.useState(""),g=i.useRef(null),v=i.useRef({}),{user:x,createEmailAddress:w,deleteEmailAddress:$,prepareEmailVerification:S,attemptEmailVerification:k,makeEmailPrimary:P}=sr();if(!((m=(y=t==null?void 0:t.auth_settings)==null?void 0:y.email_address)!=null&&m.enabled))return null;const E=async j=>{try{if(j===(x==null?void 0:x.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await $(j),x.refetch(),r("Email address deleted successfully","info")}catch(T){r(T.message||"Failed to delete email address. Please try again.","error")}},z=i.useMemo(()=>x!=null&&x.user_email_addresses?l.trim()?x.user_email_addresses.filter(j=>j.email.toLowerCase().includes(l.toLowerCase())):x.user_email_addresses:[],[x==null?void 0:x.user_email_addresses,l]);return e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{style:{marginBottom:"20px"},children:[e.jsx(St,{value:l,onChange:u,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:g,onClick:()=>f(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),p&&e.jsx(vi,{triggerRef:g,onClose:()=>f(!1),onAddEmail:async j=>{const T=await w(j);a(T.data.id),await S(T.data.id),x.refetch()},onPrepareVerification:async()=>{await S(s),x.refetch()},onAttemptVerification:async j=>{await k(s,j),x.refetch(),f(!1),a(""),r("Email added and verified successfully!","info")}})]})]}),z!=null&&z.length?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email Address"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:z.map(j=>e.jsxs(Ne,{children:[e.jsx(Me,{children:j.email}),e.jsx(Me,{children:j.id===(x==null?void 0:x.primary_email_address_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx(mt,{children:j.id!==(x==null?void 0:x.primary_email_address_id)||!j.verified?e.jsxs(nt,{open:o===j.id,openChange:T=>n(T?j.id:null),children:[e.jsx(at,{children:e.jsx(cn,{ref:T=>{T&&(v.current[j.id]=T)},children:"•••"})}),e.jsxs(st,{children:[j.id!==(x==null?void 0:x.primary_email_address_id)&&j.verified&&e.jsx(Te,{onClick:async()=>{try{await P(j.id),x.refetch(),n(null),r("Primary email updated successfully","info")}catch(T){r(T.message||"Failed to update primary email","error")}},children:"Make primary"}),!j.verified&&e.jsx(Te,{onClick:async()=>{n(null),await S(j.id),h(j.id)},children:"Verify email"}),j.id!==(x==null?void 0:x.primary_email_address_id)&&e.jsx(Te,{$destructive:!0,onClick:()=>{E(j.id),n(null)},children:"Remove"})]})]}):null})]},j.id))})]}):e.jsx(it,{title:l?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(vi,{existingEmail:(_=(b=x==null?void 0:x.user_email_addresses)==null?void 0:b.find(j=>j.id===c))==null?void 0:_.email,triggerRef:{current:v.current[c]},onClose:()=>h(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await S(c),x.refetch()},onAttemptVerification:async j=>{await k(c,j),x.refetch(),h(null),r("Email verified successfully!","info")}})]})},Cv=()=>{var z,y,m,b;const{deployment:t}=ve(),[r,o]=i.useState(null),[n,s]=i.useState(""),[a,p]=i.useState(!1),[f,c]=i.useState(null),[h,l]=i.useState(""),u=i.useRef(null),g=i.useRef({}),{user:v,createPhoneNumber:x,deletePhoneNumber:w,preparePhoneVerification:$,attemptPhoneVerification:S,makePhonePrimary:k}=sr();if(!((y=(z=t==null?void 0:t.auth_settings)==null?void 0:z.phone_number)!=null&&y.enabled))return null;const P=_=>{const j=Oo.find(T=>T.dialCode===_);return(j==null?void 0:j.flag)||"🌍"},E=i.useMemo(()=>v!=null&&v.user_phone_numbers?h.trim()?v.user_phone_numbers.filter(_=>_.phone_number.toLowerCase().includes(h.toLowerCase())):v.user_phone_numbers:[],[v==null?void 0:v.user_phone_numbers,h]);return e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{style:{marginBottom:"20px"},children:[e.jsx(St,{value:h,onChange:l,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:u,onClick:()=>p(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),a&&e.jsx(wi,{triggerRef:u,onClose:()=>p(!1),onAddPhone:async(_,j)=>{const T=await x(_,j);s(T.data.id),await $(T.data.id)},onPrepareVerification:async()=>{await $(n),v.refetch()},onAttemptVerification:async _=>{await S(n,_),v.refetch(),p(!1)}}),f&&e.jsx(wi,{existingPhone:(b=(m=v==null?void 0:v.user_phone_numbers)==null?void 0:m.find(_=>_.id===f))==null?void 0:b.phone_number,triggerRef:{current:g.current[f]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await $(f),v.refetch()},onAttemptVerification:async _=>{await S(f,_),v.refetch(),c(null)}})]})]}),E!=null&&E.length?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Phone Number"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:E.map(_=>e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:P(_.country_code)}),e.jsx("span",{children:_.country_code}),e.jsx("span",{children:_.phone_number})]})}),e.jsx(Me,{children:_.id===(v==null?void 0:v.primary_phone_number_id)?"Primary":_.verified?"Verified":"Not Verified"}),e.jsx(mt,{children:e.jsxs(nt,{open:r===_.id,openChange:j=>o(j?_.id:null),children:[e.jsx(at,{children:e.jsx(cn,{ref:j=>{j&&(g.current[_.id]=j)},children:"•••"})}),e.jsxs(st,{children:[_.id!==(v==null?void 0:v.primary_phone_number_id)&&_.verified&&e.jsx(Te,{onClick:async()=>{await k(_.id),o(null),v.refetch()},children:"Make primary"}),!_.verified&&e.jsx(Te,{onClick:async()=>{await $(_.id),c(_.id),o(null)},children:"Verify phone"}),e.jsx(Te,{$destructive:!0,onClick:async()=>{await w(_.id),o(null),v.refetch()},children:"Remove"})]})]})})]},_.id))})]}):e.jsx(it,{title:h?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},sd=d.div`
4114
4114
  width: 20px;
4115
4115
  height: 20px;
4116
4116
  flex-shrink: 0;
@@ -4125,9 +4125,9 @@ cursor: pointer;
4125
4125
  flex-shrink: 0;
4126
4126
  display: block;
4127
4127
  }
4128
- `,Sv=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=sr(),{deployment:n}=ve(),s={google_oauth:{icon:e.jsx(nl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(ol,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(rl,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(al,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(il,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(cl,{}),label:"Discord"},x_oauth:{icon:e.jsx(sl,{}),label:"X"}},i=(n==null?void 0:n.social_connections.filter(u=>u.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:i.map((u,f)=>{var l;const c=((l=t==null?void 0:t.social_connections)==null?void 0:l.filter(p=>p.provider===u.provider))||[],h=s[u.provider];return h?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(sd,{children:h.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:h.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(p=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:p.email_address}),e.jsx(cn,{onClick:async()=>{await r(p.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(et,{size:14})})]},p.id)),c.length>0?e.jsx(Q,{onClick:()=>{o({provider:u.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(Q,{onClick:()=>{o({provider:u.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<i.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},u.provider):null})})]})},id=()=>{var m,b,$,z,w,y,k;const{loading:t}=sr(),{deployment:r}=ve(),[o,n]=a.useState("profile"),[s,i]=a.useState(null),[u,f]=a.useState("info"),c=a.useCallback((C,_="info")=>{i(C),f(_),setTimeout(()=>i(null),3e3)},[i]);if(t)return e.jsx(ge,{children:e.jsx(za,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})})});const h=r==null?void 0:r.auth_settings,l=(m=h==null?void 0:h.email_address)==null?void 0:m.enabled,p=(b=h==null?void 0:h.phone_number)==null?void 0:b.enabled,g=(($=r==null?void 0:r.social_connections)==null?void 0:$.some(C=>C.enabled))||!1,x=((z=h==null?void 0:h.password)==null?void 0:z.enabled)||((w=h==null?void 0:h.auth_factors_enabled)==null?void 0:w.authenticator)||((y=h==null?void 0:h.auth_factors_enabled)==null?void 0:y.phone_otp)||((k=h==null?void 0:h.auth_factors_enabled)==null?void 0:k.backup_code);return e.jsx(ge,{children:e.jsx(xv,{children:e.jsx(nd.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(za,{children:[e.jsx(vv,{children:e.jsxs(bv,{children:[e.jsx(mr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(xr,{children:[e.jsx(Bo,{size:16}),"Profile"]})}),l&&e.jsx(mr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(xr,{children:[e.jsx(on,{size:16}),"Email"]})}),p&&e.jsx(mr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(xr,{children:[e.jsx(yh,{size:16}),"Phone"]})}),g&&e.jsx(mr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(xr,{children:[e.jsx(dh,{size:16}),"Connections"]})}),x&&e.jsx(mr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(xr,{children:[e.jsx(Qe,{size:16}),"Security"]})}),e.jsx(mr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(xr,{children:[e.jsx(Dp,{size:16}),"Sessions"]})})]})}),e.jsxs(yv,{children:[o==="profile"&&e.jsx($v,{}),o==="email"&&l&&e.jsx(kv,{}),o==="phone"&&p&&e.jsx(Cv,{}),o==="social"&&g&&e.jsx(Sv,{}),o==="security"&&x&&e.jsx(zv,{}),o==="sessions"&&e.jsx(_v,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})})},zv=()=>{var D,Y,ie;const{deployment:t}=ve(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:s,verifyAuthenticator:i,deleteAuthenticator:u,generateBackupCodes:f,regenerateBackupCodes:c,updateProfile:h}=sr(),{toast:l}=Mt(),[p,g]=a.useState((r==null?void 0:r.second_factor_policy)||"none"),[x,m]=a.useState(!1),b=async J=>{try{await h({second_factor_policy:J}),g(J),l("2FA requirement updated successfully","info")}catch(_e){l(_e.message||"Failed to update 2FA requirement","error")}},[$,z]=a.useState(!1),[w,y]=a.useState(!1),[k,C]=a.useState(!1),[_,v]=a.useState(!1),P=a.useRef(null),I=a.useRef(null),S=a.useRef(null),T=a.useRef(null),[E,j]=a.useState("table"),[R,M]=a.useState(""),[F,A]=a.useState(""),[B,O]=a.useState(""),[L,X]=a.useState(["",""]),[ee,V]=a.useState([]),[q,te]=a.useState(!1),[re,le]=a.useState(!1),[oe]=a.useState(!1),[de,Z]=a.useState(!1),se=(D=t==null?void 0:t.auth_settings)==null?void 0:D.auth_factors_enabled,xe=(ie=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.password)==null?void 0:ie.enabled;if(!(se!=null&&se.authenticator)&&!(se!=null&&se.backup_code)&&!xe)return null;const ue=async(J,_e)=>{await o(J,_e),await r.refetch(),l("Password updated successfully","info")},U=async J=>{await n(J),await r.refetch(),l("Password removed successfully","info")},pe=()=>{var Re,ar,cr,Zr,Ns,Fs;if(!r)return!1;const J=(Re=r.user_email_addresses)==null?void 0:Re.some(Er=>Er.verified),_e=(ar=r.user_phone_numbers)==null?void 0:ar.some(Er=>Er.verified),be=r.social_connections&&r.social_connections.length>0,ze=t==null?void 0:t.auth_settings;return(ze==null?void 0:ze.first_factor)==="email_otp"&&J||((cr=ze==null?void 0:ze.magic_link)==null?void 0:cr.enabled)&&J||((Zr=ze==null?void 0:ze.passkey)==null?void 0:Zr.enabled)||((Ns=ze==null?void 0:ze.auth_factors_enabled)==null?void 0:Ns.phone_otp)&&_e||be&&((Fs=t==null?void 0:t.social_connections)==null?void 0:Fs.some(Er=>Er.enabled))},K=async()=>{if(L.some(J=>J.length!==6)){l("Please enter both 6-digit verification codes","error");return}try{if(le(!0),await i(B,L),await r.refetch(),se!=null&&se.backup_code){const J=await f();V(J),await r.refetch(),j("backup")}else j("success")}catch(J){l(J.message||"Invalid verification codes","error")}finally{le(!1)}},H=()=>{j("table"),M(""),A(""),O(""),X(["",""]),V([]),l("Two-factor authentication setup completed successfully!","info")},ne=async()=>{var J;if((J=r==null?void 0:r.user_authenticator)!=null&&J.id)try{Z(!0),await u(r.user_authenticator.id),await r.refetch(),m(!1),l("Two-factor authentication removed successfully","info")}catch(_e){l(_e.message||"Failed to remove authenticator","error")}finally{Z(!1)}},me=async()=>{if(!q)try{te(!0);const J=await c();V(J),await r.refetch(),v(!0),l("New backup codes generated","info")}catch(J){l(J.message||"Failed to generate backup codes","error")}finally{te(!1)}},fe=()=>{const J=ee.join(`
4129
- `);navigator.clipboard.writeText(J).then(()=>{l("Backup codes copied to clipboard","info")}).catch(()=>{l("Failed to copy backup codes","error")})},W=()=>{const J=ee.join(`
4130
- `),_e=new Blob([J],{type:"text/plain"}),be=URL.createObjectURL(_e),ze=document.createElement("a");ze.href=be,ze.download="wacht-backup-codes.txt",ze.click(),URL.revokeObjectURL(be),l("Backup codes downloaded","info")},N=[];return xe&&N.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"]}),se!=null&&se.authenticator&&N.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&N.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),r!=null&&r.user_authenticator&&N.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:p==="enforced"?"Enforced":"Optional",actions:["toggle"]}),E!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Qe,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[E==="qr"&&"Setup Two-Factor Authentication",E==="verify"&&"Verify Your Authenticator",E==="backup"&&"Save Your Backup Codes",E==="success"&&"Setup Complete!"]})]}),e.jsx(Q,{onClick:()=>j("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[E==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:oe?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${mv} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):R?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Ls,{value:R,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:F||"Loading..."})]}),e.jsx(Q,{onClick:()=>j("verify"),disabled:!R||!F,style:{padding:"10px 20px",background:!R||!F?"var(--color-border)":"var(--color-primary)",color:!R||!F?"var(--color-secondary-text)":"white",border:`1px solid ${!R||!F?"var(--color-border)":"var(--color-primary)"}`,cursor:!R||!F?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),E==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(ce,{type:"text",placeholder:"000000",value:L[0],onChange:J=>{const _e=J.target.value.replace(/[^0-9]/g,"").substring(0,6);X([_e,L[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(ce,{type:"text",placeholder:"000000",value:L[1],onChange:J=>{const _e=J.target.value.replace(/[^0-9]/g,"").substring(0,6);X([L[0],_e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(Q,{onClick:()=>j("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(Q,{onClick:K,disabled:re||L.some(J=>J.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:re?"Verifying...":"Verify & Continue"})]})]}),E==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ut,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:ee.map((J,_e)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(J),children:J},_e))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(Q,{onClick:fe,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(Q,{onClick:W,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(rn,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(Q,{onClick:H,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),E==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(Ve,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(Q,{onClick:H,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ho,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),N.length?e.jsx("div",{children:N.map((J,_e)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:J.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:J.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:J.status==="Enabled"||J.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:J.status==="Enabled"||J.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:J.status}),e.jsxs("div",{style:{position:"relative"},children:[J.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:I,onClick:()=>y(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),w&&e.jsx(Ca,{triggerRef:I,onClose:()=>y(!1),onChangePassword:ue})]}),pe()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:S,onClick:()=>C(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),k&&e.jsx(rv,{triggerRef:S,onClose:()=>C(!1),onRemovePassword:U})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:I,onClick:()=>y(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),w&&e.jsx(Ca,{triggerRef:I,onClose:()=>y(!1),onChangePassword:ue,isSetup:!0})]})}),J.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:P,onClick:()=>z(!0),disabled:oe,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:oe?"Setting up...":"Setup"}),$&&e.jsx(q0,{triggerRef:P,onClose:()=>z(!1),onSetupTOTP:async()=>{const be=await s();return O(be.id),be},onVerifyTOTP:async be=>{await i(B,be),await r.refetch(),l("Two-factor authentication enabled successfully!","info")}})]})}),J.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{onClick:()=>m(!0),disabled:de,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:de?"not-allowed":"pointer",opacity:de?.6:1},children:de?"Removing...":"Remove"}),x&&e.jsx(Yr,{title:"Remove MFA and reset policy to default?",onConfirm:ne,onCancel:()=>m(!1)})]}),J.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:T,onClick:me,disabled:q,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:q?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),_&&e.jsx(lv,{triggerRef:T,codes:ee,onClose:()=>v(!1),onCopy:fe,onDownload:W})]})}),J.id==="second_factor_policy"&&e.jsx(Cr,{checked:p==="enforced",onChange:be=>{b(be?"enforced":"none")}})]})]})]}),_e<N.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},J.id))}):e.jsx(at,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},$v=()=>{var A,B;const{deployment:t}=ve(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:s}=sr(),{toast:i}=Mt(),[u,f]=a.useState(""),[c,h]=a.useState(""),[l,p]=a.useState(""),[g,x]=a.useState(!1),[m,b]=a.useState(!1),[$,z]=a.useState(!1),[w,y]=a.useState(""),[k,C]=a.useState((r==null?void 0:r.profile_picture_url)||null),_=a.useRef(null);a.useEffect(()=>{r&&!g&&(f(r.first_name||""),h(r.last_name||""),p(r.username||""),C(r.profile_picture_url||null),x(!0))},[r,g]);const v=a.useCallback(async()=>{if(r)try{const O={};u!==r.first_name&&(O.first_name=u),c!==r.last_name&&(O.last_name=c),l!==r.username&&(O.username=l),Object.keys(O).length>0&&await o(O)}catch(O){i(O.message||"Failed to save profile changes","error")}},[r,o,u,c,l,i]),P=O=>{f(O.target.value)},I=O=>{h(O.target.value)},S=O=>{p(O.target.value)},T=()=>{v()},E=()=>{v()},j=()=>{v()},R=O=>{var L;if((L=O.target.files)!=null&&L[0]){const X=O.target.files[0];C(URL.createObjectURL(X)),setTimeout(async()=>{try{await n(X),r.refetch(),i("Profile picture updated successfully","info")}catch(ee){i(ee.message||"Failed to update profile picture","error"),C((r==null?void 0:r.profile_picture_url)||null)}},100)}},M=()=>{_.current&&_.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const F=async()=>{if(!(!r||w!==r.username)){z(!0);try{await s(""),i("Account deleted successfully","info")}catch(O){i(O.message||"Failed to delete account","error")}finally{z(!1),y(""),b(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:k?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,onMouseEnter:O=>{O.currentTarget.style.borderColor="var(--color-primary)",O.currentTarget.style.transform="scale(1.02)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--color-border)",O.currentTarget.style.transform="scale(1)"},children:[k?e.jsx("img",{src:k,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Bo,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:_,style:{display:"none"},accept:"image/*",onChange:R})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var O;return(O=_.current)==null?void 0:O.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(rn,{size:14}),k?"Change":"Upload"]}),e.jsxs(Q,{onClick:async()=>{C(null),_.current&&(_.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),i("Profile picture removed successfully","info")}catch(O){i(O.message||"Failed to remove profile picture","error"),C((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ut,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ae,{htmlFor:"firstName",children:"First Name"}),e.jsx(ce,{id:"firstName",type:"text",value:u,onChange:P,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ae,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ce,{id:"lastName",type:"text",value:c,onChange:I,onBlur:E,placeholder:"Enter your last name",required:!0})]})]}),((B=(A=t==null?void 0:t.auth_settings)==null?void 0:A.username)==null?void 0:B.enabled)&&e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"username",children:"Username"}),e.jsx(ce,{id:"username",type:"text",value:l,onChange:S,onBlur:j,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:m?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{m?(b(!1),y("")):b(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:m?"Cancel":"Delete"})]}),m&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ae,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(ce,{id:"confirm_username",type:"text",value:w,onChange:O=>y(O.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(Q,{onClick:F,disabled:w!==(r==null?void 0:r.username)||$,style:{background:w===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:w===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:w===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:w===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:$?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})})},ad=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:i,customContent:u,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),u||f||e.jsx(id,{}),i&&e.jsx(ke.Footer,{children:i})]})})}),Ev=d.div`
4128
+ `,Sv=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=sr(),{deployment:n}=ve(),s={google_oauth:{icon:e.jsx(nl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(ol,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(rl,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(il,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(al,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(cl,{}),label:"Discord"},x_oauth:{icon:e.jsx(sl,{}),label:"X"}},a=(n==null?void 0:n.social_connections.filter(p=>p.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:a.map((p,f)=>{var l;const c=((l=t==null?void 0:t.social_connections)==null?void 0:l.filter(u=>u.provider===p.provider))||[],h=s[p.provider];return h?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(sd,{children:h.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:h.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(u=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:u.email_address}),e.jsx(cn,{onClick:async()=>{await r(u.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(et,{size:14})})]},u.id)),c.length>0?e.jsx(Q,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(Q,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<a.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},ad=()=>{var x,w,$,S,k,P,E;const{loading:t}=sr(),{deployment:r}=ve(),[o,n]=i.useState("profile"),[s,a]=i.useState(null),[p,f]=i.useState("info"),c=i.useCallback((z,y="info")=>{a(z),f(y),setTimeout(()=>a(null),3e3)},[a]);if(t)return e.jsx(ge,{children:e.jsx(zi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})})});const h=r==null?void 0:r.auth_settings,l=(x=h==null?void 0:h.email_address)==null?void 0:x.enabled,u=(w=h==null?void 0:h.phone_number)==null?void 0:w.enabled,g=(($=r==null?void 0:r.social_connections)==null?void 0:$.some(z=>z.enabled))||!1,v=((S=h==null?void 0:h.password)==null?void 0:S.enabled)||((k=h==null?void 0:h.auth_factors_enabled)==null?void 0:k.authenticator)||((P=h==null?void 0:h.auth_factors_enabled)==null?void 0:P.phone_otp)||((E=h==null?void 0:h.auth_factors_enabled)==null?void 0:E.backup_code);return e.jsx(ge,{children:e.jsx(xv,{children:e.jsx(nd.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(zi,{children:[e.jsx(vv,{children:e.jsxs(bv,{children:[e.jsx(mr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(xr,{children:[e.jsx(Bo,{size:16}),"Profile"]})}),l&&e.jsx(mr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(xr,{children:[e.jsx(on,{size:16}),"Email"]})}),u&&e.jsx(mr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(xr,{children:[e.jsx(yh,{size:16}),"Phone"]})}),g&&e.jsx(mr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(xr,{children:[e.jsx(dh,{size:16}),"Connections"]})}),v&&e.jsx(mr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(xr,{children:[e.jsx(Qe,{size:16}),"Security"]})}),e.jsx(mr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(xr,{children:[e.jsx(Dp,{size:16}),"Sessions"]})})]})}),e.jsxs(yv,{children:[o==="profile"&&e.jsx($v,{}),o==="email"&&l&&e.jsx(kv,{}),o==="phone"&&u&&e.jsx(Cv,{}),o==="social"&&g&&e.jsx(Sv,{}),o==="security"&&v&&e.jsx(zv,{}),o==="sessions"&&e.jsx(_v,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})})},zv=()=>{var D,Y,ie;const{deployment:t}=ve(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:s,verifyAuthenticator:a,deleteAuthenticator:p,generateBackupCodes:f,regenerateBackupCodes:c,updateProfile:h}=sr(),{toast:l}=Mt(),[u,g]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[v,x]=i.useState(!1),w=async ee=>{try{await h({second_factor_policy:ee}),g(ee),l("2FA requirement updated successfully","info")}catch(_e){l(_e.message||"Failed to update 2FA requirement","error")}},[$,S]=i.useState(!1),[k,P]=i.useState(!1),[E,z]=i.useState(!1),[y,m]=i.useState(!1),b=i.useRef(null),_=i.useRef(null),j=i.useRef(null),T=i.useRef(null),[R,C]=i.useState("table"),[I,M]=i.useState(""),[F,L]=i.useState(""),[B,O]=i.useState(""),[A,X]=i.useState(["",""]),[te,V]=i.useState([]),[q,re]=i.useState(!1),[ne,J]=i.useState(!1),[oe]=i.useState(!1),[de,Z]=i.useState(!1),ae=(D=t==null?void 0:t.auth_settings)==null?void 0:D.auth_factors_enabled,xe=(ie=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.password)==null?void 0:ie.enabled;if(!(ae!=null&&ae.authenticator)&&!(ae!=null&&ae.backup_code)&&!xe)return null;const ue=async(ee,_e)=>{await o(ee,_e),await r.refetch(),l("Password updated successfully","info")},U=async ee=>{await n(ee),await r.refetch(),l("Password removed successfully","info")},pe=()=>{var Re,ir,cr,Zr,Ns,Fs;if(!r)return!1;const ee=(Re=r.user_email_addresses)==null?void 0:Re.some(Er=>Er.verified),_e=(ir=r.user_phone_numbers)==null?void 0:ir.some(Er=>Er.verified),be=r.social_connections&&r.social_connections.length>0,ze=t==null?void 0:t.auth_settings;return(ze==null?void 0:ze.first_factor)==="email_otp"&&ee||((cr=ze==null?void 0:ze.magic_link)==null?void 0:cr.enabled)&&ee||((Zr=ze==null?void 0:ze.passkey)==null?void 0:Zr.enabled)||((Ns=ze==null?void 0:ze.auth_factors_enabled)==null?void 0:Ns.phone_otp)&&_e||be&&((Fs=t==null?void 0:t.social_connections)==null?void 0:Fs.some(Er=>Er.enabled))},K=async()=>{if(A.some(ee=>ee.length!==6)){l("Please enter both 6-digit verification codes","error");return}try{if(J(!0),await a(B,A),await r.refetch(),ae!=null&&ae.backup_code){const ee=await f();V(ee),await r.refetch(),C("backup")}else C("success")}catch(ee){l(ee.message||"Invalid verification codes","error")}finally{J(!1)}},H=()=>{C("table"),M(""),L(""),O(""),X(["",""]),V([]),l("Two-factor authentication setup completed successfully!","info")},se=async()=>{var ee;if((ee=r==null?void 0:r.user_authenticator)!=null&&ee.id)try{Z(!0),await p(r.user_authenticator.id),await r.refetch(),x(!1),l("Two-factor authentication removed successfully","info")}catch(_e){l(_e.message||"Failed to remove authenticator","error")}finally{Z(!1)}},me=async()=>{if(!q)try{re(!0);const ee=await c();V(ee),await r.refetch(),m(!0),l("New backup codes generated","info")}catch(ee){l(ee.message||"Failed to generate backup codes","error")}finally{re(!1)}},fe=()=>{const ee=te.join(`
4129
+ `);navigator.clipboard.writeText(ee).then(()=>{l("Backup codes copied to clipboard","info")}).catch(()=>{l("Failed to copy backup codes","error")})},W=()=>{const ee=te.join(`
4130
+ `),_e=new Blob([ee],{type:"text/plain"}),be=URL.createObjectURL(_e),ze=document.createElement("a");ze.href=be,ze.download="wacht-backup-codes.txt",ze.click(),URL.revokeObjectURL(be),l("Backup codes downloaded","info")},N=[];return xe&&N.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"]}),ae!=null&&ae.authenticator&&N.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&N.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),r!=null&&r.user_authenticator&&N.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:u==="enforced"?"Enforced":"Optional",actions:["toggle"]}),R!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Qe,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[R==="qr"&&"Setup Two-Factor Authentication",R==="verify"&&"Verify Your Authenticator",R==="backup"&&"Save Your Backup Codes",R==="success"&&"Setup Complete!"]})]}),e.jsx(Q,{onClick:()=>C("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[R==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:oe?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${mv} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):I?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Ls,{value:I,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:F||"Loading..."})]}),e.jsx(Q,{onClick:()=>C("verify"),disabled:!I||!F,style:{padding:"10px 20px",background:!I||!F?"var(--color-border)":"var(--color-primary)",color:!I||!F?"var(--color-secondary-text)":"white",border:`1px solid ${!I||!F?"var(--color-border)":"var(--color-primary)"}`,cursor:!I||!F?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),R==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(le,{type:"text",placeholder:"000000",value:A[0],onChange:ee=>{const _e=ee.target.value.replace(/[^0-9]/g,"").substring(0,6);X([_e,A[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(le,{type:"text",placeholder:"000000",value:A[1],onChange:ee=>{const _e=ee.target.value.replace(/[^0-9]/g,"").substring(0,6);X([A[0],_e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(Q,{onClick:()=>C("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(Q,{onClick:K,disabled:ne||A.some(ee=>ee.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:ne?"Verifying...":"Verify & Continue"})]})]}),R==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ut,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:te.map((ee,_e)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(ee),children:ee},_e))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(Q,{onClick:fe,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(Q,{onClick:W,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(rn,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(Q,{onClick:H,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),R==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(Ve,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(Q,{onClick:H,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ho,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),N.length?e.jsx("div",{children:N.map((ee,_e)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:ee.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:ee.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:ee.status==="Enabled"||ee.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:ee.status==="Enabled"||ee.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:ee.status}),e.jsxs("div",{style:{position:"relative"},children:[ee.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:_,onClick:()=>P(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),k&&e.jsx(Ci,{triggerRef:_,onClose:()=>P(!1),onChangePassword:ue})]}),pe()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:j,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),E&&e.jsx(rv,{triggerRef:j,onClose:()=>z(!1),onRemovePassword:U})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:_,onClick:()=>P(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),k&&e.jsx(Ci,{triggerRef:_,onClose:()=>P(!1),onChangePassword:ue,isSetup:!0})]})}),ee.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:b,onClick:()=>S(!0),disabled:oe,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:oe?"Setting up...":"Setup"}),$&&e.jsx(q0,{triggerRef:b,onClose:()=>S(!1),onSetupTOTP:async()=>{const be=await s();return O(be.id),be},onVerifyTOTP:async be=>{await a(B,be),await r.refetch(),l("Two-factor authentication enabled successfully!","info")}})]})}),ee.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{onClick:()=>x(!0),disabled:de,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:de?"not-allowed":"pointer",opacity:de?.6:1},children:de?"Removing...":"Remove"}),v&&e.jsx(Yr,{title:"Remove MFA and reset policy to default?",onConfirm:se,onCancel:()=>x(!1)})]}),ee.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:T,onClick:me,disabled:q,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:q?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),y&&e.jsx(lv,{triggerRef:T,codes:te,onClose:()=>m(!1),onCopy:fe,onDownload:W})]})}),ee.id==="second_factor_policy"&&e.jsx(Cr,{checked:u==="enforced",onChange:be=>{w(be?"enforced":"none")}})]})]})]}),_e<N.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},ee.id))}):e.jsx(it,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},$v=()=>{var L,B;const{deployment:t}=ve(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:s}=sr(),{toast:a}=Mt(),[p,f]=i.useState(""),[c,h]=i.useState(""),[l,u]=i.useState(""),[g,v]=i.useState(!1),[x,w]=i.useState(!1),[$,S]=i.useState(!1),[k,P]=i.useState(""),[E,z]=i.useState((r==null?void 0:r.profile_picture_url)||null),y=i.useRef(null);i.useEffect(()=>{r&&!g&&(f(r.first_name||""),h(r.last_name||""),u(r.username||""),z(r.profile_picture_url||null),v(!0))},[r,g]);const m=i.useCallback(async()=>{if(r)try{const O={};p!==r.first_name&&(O.first_name=p),c!==r.last_name&&(O.last_name=c),l!==r.username&&(O.username=l),Object.keys(O).length>0&&await o(O)}catch(O){a(O.message||"Failed to save profile changes","error")}},[r,o,p,c,l,a]),b=O=>{f(O.target.value)},_=O=>{h(O.target.value)},j=O=>{u(O.target.value)},T=()=>{m()},R=()=>{m()},C=()=>{m()},I=O=>{var A;if((A=O.target.files)!=null&&A[0]){const X=O.target.files[0];z(URL.createObjectURL(X)),setTimeout(async()=>{try{await n(X),r.refetch(),a("Profile picture updated successfully","info")}catch(te){a(te.message||"Failed to update profile picture","error"),z((r==null?void 0:r.profile_picture_url)||null)}},100)}},M=()=>{y.current&&y.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const F=async()=>{if(!(!r||k!==r.username)){S(!0);try{await s(""),a("Account deleted successfully","info")}catch(O){a(O.message||"Failed to delete account","error")}finally{S(!1),P(""),w(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:E?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,onMouseEnter:O=>{O.currentTarget.style.borderColor="var(--color-primary)",O.currentTarget.style.transform="scale(1.02)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--color-border)",O.currentTarget.style.transform="scale(1)"},children:[E?e.jsx("img",{src:E,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Bo,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:I})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var O;return(O=y.current)==null?void 0:O.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(rn,{size:14}),E?"Change":"Upload"]}),e.jsxs(Q,{onClick:async()=>{z(null),y.current&&(y.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),a("Profile picture removed successfully","info")}catch(O){a(O.message||"Failed to remove profile picture","error"),z((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ut,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ce,{htmlFor:"firstName",children:"First Name"}),e.jsx(le,{id:"firstName",type:"text",value:p,onChange:b,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ce,{htmlFor:"lastName",children:"Last Name"}),e.jsx(le,{id:"lastName",type:"text",value:c,onChange:_,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((B=(L=t==null?void 0:t.auth_settings)==null?void 0:L.username)==null?void 0:B.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"username",children:"Username"}),e.jsx(le,{id:"username",type:"text",value:l,onChange:j,onBlur:C,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:x?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{x?(w(!1),P("")):w(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:x?"Cancel":"Delete"})]}),x&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(le,{id:"confirm_username",type:"text",value:k,onChange:O=>P(O.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(Q,{onClick:F,disabled:k!==(r==null?void 0:r.username)||$,style:{background:k===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:k===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:k===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:k===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:$?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})})},id=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:p,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),p||f||e.jsx(ad,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Ev=d.div`
4131
4131
  position: relative;
4132
4132
  `,Iv=d.button`
4133
4133
  display: flex;
@@ -4163,11 +4163,11 @@ cursor: pointer;
4163
4163
  font-size: 14px;
4164
4164
  font-weight: 400;
4165
4165
  color: var(--color-foreground);
4166
- `,$a=d.span`
4166
+ `,$i=d.span`
4167
4167
  font-size: 14px;
4168
4168
  font-weight: 400;
4169
4169
  color: var(--color-foreground);
4170
- `,Ea=d.span`
4170
+ `,Ei=d.span`
4171
4171
  font-size: 12px;
4172
4172
  color: var(--color-secondary-text);
4173
4173
  `,Rv=d.div`
@@ -4191,7 +4191,7 @@ cursor: pointer;
4191
4191
  max-width: calc(100vw - 24px);
4192
4192
  max-height: ${t=>t.$maxHeight?`${t.$maxHeight}px`:"calc(100vh - 48px)"};
4193
4193
  overflow-y: auto;
4194
- `,Ia=d.div`
4194
+ `,Ii=d.div`
4195
4195
  padding: 12px;
4196
4196
  cursor: ${t=>t.$isClickable?"pointer":"default"};
4197
4197
  transition: background-color 0.2s ease;
@@ -4199,22 +4199,22 @@ cursor: pointer;
4199
4199
  &:hover {
4200
4200
  background: ${t=>t.$isClickable?"var(--color-background-hover)":"transparent"};
4201
4201
  }
4202
- `,Pa=d.div`
4202
+ `,Pi=d.div`
4203
4203
  display: flex;
4204
4204
  align-items: center;
4205
4205
  gap: 12px;
4206
- `,Ra=d.div`
4206
+ `,Ri=d.div`
4207
4207
  display: flex;
4208
4208
  flex: 1;
4209
4209
  flex-direction: column;
4210
- `,Ta=d.div`
4210
+ `,Ti=d.div`
4211
4211
  display: flex;
4212
4212
  align-items: center;
4213
4213
  justify-content: space-between;
4214
- `,Ma=d(cd)`
4214
+ `,Mi=d(cd)`
4215
4215
  width: 40px;
4216
4216
  height: 40px;
4217
- `,Oa=d.div`
4217
+ `,Oi=d.div`
4218
4218
  display: flex;
4219
4219
  margin-top: 12px;
4220
4220
  gap: 8px;
@@ -4242,10 +4242,10 @@ cursor: pointer;
4242
4242
  width: 14px;
4243
4243
  height: 14px;
4244
4244
  }
4245
- `,Aa=d.div`
4245
+ `,Ai=d.div`
4246
4246
  background: var(--color-background-hover);
4247
4247
  padding: 8px 12px;
4248
- `,La=d.button`
4248
+ `,Li=d.button`
4249
4249
  display: flex;
4250
4250
  width: 100%;
4251
4251
  align-items: center;
@@ -4266,7 +4266,7 @@ cursor: pointer;
4266
4266
  width: 14px;
4267
4267
  height: 14px;
4268
4268
  }
4269
- `,Ds=({showName:t=!0})=>{var _,v,P,I;const[r,o]=a.useState(!1),n=a.useRef(null),s=a.useRef(null),i=Fl({triggerRef:n,isOpen:r,minWidth:380}),u=Dr(!1),{session:f,signOut:c,switchSignIn:h,refetch:l}=Ue(),{navigateToSignIn:p}=Ge(),{deployment:g}=ve(),x=(_=f==null?void 0:f.active_signin)==null?void 0:_.user,m=((P=(v=g==null?void 0:g.auth_settings)==null?void 0:v.multi_session_support)==null?void 0:P.enabled)??!1,b=(((I=f==null?void 0:f.signins)==null?void 0:I.length)??0)>1;a.useEffect(()=>{if(!r)return;const S=setTimeout(()=>{const T=E=>{var R,M;const j=E.target;(R=n.current)!=null&&R.contains(j)||(M=s.current)!=null&&M.contains(j)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(S)}},[r]);const $=()=>{o(!r)},z=S=>S.split(" ").map(T=>T[0]).join("").toUpperCase(),w=async S=>{try{await c(S),await l(),o(!1)}catch{}},y=async()=>{try{await c(),await l(),o(!1)}catch{}},k=async S=>{try{await h(S),await l(),o(!1)}catch{}},C=()=>{u.open(),o(!1)};return e.jsx(ge,{children:e.jsxs(Ev,{children:[e.jsxs(Iv,{ref:n,onClick:$,children:[e.jsx(Yn,{children:e.jsx(cd,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):z(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(Pv,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&Wr.createPortal(e.jsx(ge,{children:e.jsx(Rv,{ref:s,$position:i,$isOpen:r,$maxHeight:i==null?void 0:i.maxHeight,children:e.jsxs("div",{children:[m?(()=>{const S=[...(f==null?void 0:f.signins)||[]].sort((T,E)=>{const j=T.user.id===(x==null?void 0:x.id),R=E.user.id===(x==null?void 0:x.id);return j&&!R?-1:!j&&R?1:0});return S.map(({user:T,id:E},j)=>{const R=T.id===(x==null?void 0:x.id),M=!R;return e.jsxs(a.Fragment,{children:[e.jsxs(Ia,{$isClickable:M,onClick:M?()=>k(E):void 0,children:[e.jsxs(Pa,{children:[e.jsx(Yn,{children:e.jsx(Ma,{children:T.has_profile_picture?e.jsx("img",{src:T.profile_picture_url,alt:T.first_name}):z(`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`)})}),e.jsxs(Ra,{children:[e.jsx(Ta,{children:e.jsx($a,{children:`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`})}),e.jsx(Ea,{children:T.primary_email_address.email})]})]}),R&&e.jsxs(Oa,{children:[e.jsxs($o,{onClick:C,children:[e.jsx(er,{}),"Manage account"]}),e.jsxs($o,{$destructive:!0,onClick:()=>w(E),children:[e.jsx(It,{}),"Sign out"]})]})]}),j===0&&S.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},T.id)})})():x&&e.jsxs(Ia,{$isClickable:!1,children:[e.jsxs(Pa,{children:[e.jsx(Yn,{children:e.jsx(Ma,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):z(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(Ra,{children:[e.jsx(Ta,{children:e.jsx($a,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(Ea,{children:x.primary_email_address.email})]})]}),e.jsxs(Oa,{children:[e.jsxs($o,{onClick:C,children:[e.jsx(er,{}),"Manage account"]}),e.jsxs($o,{$destructive:!0,onClick:()=>{var S;return w(((S=f==null?void 0:f.active_signin)==null?void 0:S.id)||"")},children:[e.jsx(It,{}),"Sign out"]})]})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx(Aa,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(La,{onClick:()=>p(),children:[e.jsx(Ke,{}),"Add new account"]})}),b&&e.jsx(Aa,{children:e.jsxs(La,{onClick:y,children:[e.jsx(It,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(ad,{isOpen:u.isOpen,onClose:u.close})]})})},Tv=d.div`
4269
+ `,Ds=({showName:t=!0})=>{var y,m,b,_;const[r,o]=i.useState(!1),n=i.useRef(null),s=i.useRef(null),a=Fl({triggerRef:n,isOpen:r,minWidth:380}),p=Dr(!1),{session:f,signOut:c,switchSignIn:h,refetch:l}=Ue(),{navigateToSignIn:u}=Ge(),{deployment:g}=ve(),v=(y=f==null?void 0:f.active_signin)==null?void 0:y.user,x=((b=(m=g==null?void 0:g.auth_settings)==null?void 0:m.multi_session_support)==null?void 0:b.enabled)??!1,w=(((_=f==null?void 0:f.signins)==null?void 0:_.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const T=R=>{var I,M;const C=R.target;(I=n.current)!=null&&I.contains(C)||(M=s.current)!=null&&M.contains(C)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(j)}},[r]);const $=()=>{o(!r)},S=j=>j.split(" ").map(T=>T[0]).join("").toUpperCase(),k=async j=>{try{await c(j),await l(),o(!1)}catch{}},P=async()=>{try{await c(),await l(),o(!1)}catch{}},E=async j=>{try{await h(j),await l(),o(!1)}catch{}},z=()=>{p.open(),o(!1)};return e.jsx(ge,{children:e.jsxs(Ev,{children:[e.jsxs(Iv,{ref:n,onClick:$,children:[e.jsx(Yn,{children:e.jsx(cd,{children:v!=null&&v.has_profile_picture?e.jsx("img",{src:v.profile_picture_url,alt:v.first_name}):S(`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`)})}),t&&e.jsx(Pv,{children:`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`})]}),typeof window<"u"&&r&&Wr.createPortal(e.jsx(ge,{children:e.jsx(Rv,{ref:s,$position:a,$isOpen:r,$maxHeight:a==null?void 0:a.maxHeight,children:e.jsxs("div",{children:[x?(()=>{const j=[...(f==null?void 0:f.signins)||[]].sort((T,R)=>{const C=T.user.id===(v==null?void 0:v.id),I=R.user.id===(v==null?void 0:v.id);return C&&!I?-1:!C&&I?1:0});return j.map(({user:T,id:R},C)=>{const I=T.id===(v==null?void 0:v.id),M=!I;return e.jsxs(i.Fragment,{children:[e.jsxs(Ii,{$isClickable:M,onClick:M?()=>E(R):void 0,children:[e.jsxs(Pi,{children:[e.jsx(Yn,{children:e.jsx(Mi,{children:T.has_profile_picture?e.jsx("img",{src:T.profile_picture_url,alt:T.first_name}):S(`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`)})}),e.jsxs(Ri,{children:[e.jsx(Ti,{children:e.jsx($i,{children:`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`})}),e.jsx(Ei,{children:T.primary_email_address.email})]})]}),I&&e.jsxs(Oi,{children:[e.jsxs($o,{onClick:z,children:[e.jsx(er,{}),"Manage account"]}),e.jsxs($o,{$destructive:!0,onClick:()=>k(R),children:[e.jsx(Et,{}),"Sign out"]})]})]}),C===0&&j.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},T.id)})})():v&&e.jsxs(Ii,{$isClickable:!1,children:[e.jsxs(Pi,{children:[e.jsx(Yn,{children:e.jsx(Mi,{children:v.has_profile_picture?e.jsx("img",{src:v.profile_picture_url,alt:v.first_name}):S(`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`)})}),e.jsxs(Ri,{children:[e.jsx(Ti,{children:e.jsx($i,{children:`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`})}),e.jsx(Ei,{children:v.primary_email_address.email})]})]}),e.jsxs(Oi,{children:[e.jsxs($o,{onClick:z,children:[e.jsx(er,{}),"Manage account"]}),e.jsxs($o,{$destructive:!0,onClick:()=>{var j;return k(((j=f==null?void 0:f.active_signin)==null?void 0:j.id)||"")},children:[e.jsx(Et,{}),"Sign out"]})]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsx(Ai,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(Li,{onClick:()=>u(),children:[e.jsx(Ke,{}),"Add new account"]})}),w&&e.jsx(Ai,{children:e.jsxs(Li,{onClick:P,children:[e.jsx(Et,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(id,{isOpen:p.isOpen,onClose:p.close})]})})},Tv=d.div`
4270
4270
  padding: var(--space-md) var(--space-lg);
4271
4271
  background: ${t=>t.$unread?"var(--color-background-hover)":"transparent"};
4272
4272
  transition: all 0.2s ease;
@@ -4375,7 +4375,7 @@ cursor: pointer;
4375
4375
  width: 12px;
4376
4376
  height: 12px;
4377
4377
  }
4378
- `;function ld({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},s=i=>{const u=new Date(i),c=new Date().getTime()-u.getTime(),h=Math.floor(c/1e3),l=Math.floor(h/60),p=Math.floor(l/60),g=Math.floor(p/24);return g>7?u.toLocaleDateString():g>0?`${g}d ago`:p>0?`${p}h ago`:l>0?`${l}m ago`:"Just now"};return e.jsxs(Tv,{$unread:!t.is_read,onClick:n,children:[e.jsxs(Mv,{children:[e.jsxs(Ov,{children:[e.jsx(Lv,{$severity:t.severity}),e.jsx(Av,{children:t.title})]}),e.jsx(Uv,{onClick:i=>{i.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(et,{})})]}),e.jsx(Dv,{children:t.body}),e.jsxs(Nv,{children:[e.jsx(Fv,{children:s(t.created_at)}),t.action_url&&e.jsx(Bv,{children:e.jsxs(Wv,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:i=>i.stopPropagation(),children:[t.action_label||"View",e.jsx(zs,{})]})})]})]})}const Vv=d.div`
4378
+ `;function ld({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},s=a=>{const p=new Date(a),c=new Date().getTime()-p.getTime(),h=Math.floor(c/1e3),l=Math.floor(h/60),u=Math.floor(l/60),g=Math.floor(u/24);return g>7?p.toLocaleDateString():g>0?`${g}d ago`:u>0?`${u}h ago`:l>0?`${l}m ago`:"Just now"};return e.jsxs(Tv,{$unread:!t.is_read,onClick:n,children:[e.jsxs(Mv,{children:[e.jsxs(Ov,{children:[e.jsx(Lv,{$severity:t.severity}),e.jsx(Av,{children:t.title})]}),e.jsx(Uv,{onClick:a=>{a.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(et,{})})]}),e.jsx(Dv,{children:t.body}),e.jsxs(Nv,{children:[e.jsx(Fv,{children:s(t.created_at)}),t.action_url&&e.jsx(Bv,{children:e.jsxs(Wv,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:a=>a.stopPropagation(),children:[t.action_label||"View",e.jsx(zs,{})]})})]})]})}const Vv=d.div`
4379
4379
  position: fixed;
4380
4380
  ${t=>{var r;return((r=t.$position)==null?void 0:r.top)!==void 0?`top: ${t.$position.top}px;`:""}}
4381
4381
  ${t=>{var r;return((r=t.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${t.$position.bottom}px;`:""}}
@@ -4486,7 +4486,7 @@ cursor: pointer;
4486
4486
  color: var(--color-primary-hover);
4487
4487
  text-decoration: underline;
4488
4488
  }
4489
- `,dd=a.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:s,onDelete:i},u)=>{const f=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(Vv,{ref:u,$position:t,children:[e.jsxs(Gv,{children:[e.jsx(Hv,{children:"Notifications"}),f&&e.jsx(qv,{onClick:s,children:"Mark all as read"})]}),e.jsx(Yv,{children:o?e.jsx(Zv,{children:e.jsx(Ee,{})}):r.length===0?e.jsxs(Kv,{children:[e.jsx(Qv,{children:e.jsx(Fp,{})}),e.jsx(Xv,{children:"No notifications"}),e.jsx(Jv,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(ld,{notification:c,onMarkAsRead:n,onDelete:i},c.id))}),!o&&r.length>0&&e.jsx(e1,{children:e.jsx(t1,{href:"/notifications",children:"View all notifications"})})]})}),r1=d.div`
4489
+ `,dd=i.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:s,onDelete:a},p)=>{const f=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(Vv,{ref:p,$position:t,children:[e.jsxs(Gv,{children:[e.jsx(Hv,{children:"Notifications"}),f&&e.jsx(qv,{onClick:s,children:"Mark all as read"})]}),e.jsx(Yv,{children:o?e.jsx(Zv,{children:e.jsx(Ee,{})}):r.length===0?e.jsxs(Kv,{children:[e.jsx(Qv,{children:e.jsx(Fp,{})}),e.jsx(Xv,{children:"No notifications"}),e.jsx(Jv,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(ld,{notification:c,onMarkAsRead:n,onDelete:a},c.id))}),!o&&r.length>0&&e.jsx(e1,{children:e.jsx(t1,{href:"/notifications",children:"View all notifications"})})]})}),r1=d.div`
4490
4490
  position: relative;
4491
4491
  `,o1=d.div`
4492
4492
  width: 40px;
@@ -4549,46 +4549,46 @@ cursor: pointer;
4549
4549
  justify-content: center;
4550
4550
  border: 2px solid var(--color-background);
4551
4551
  box-shadow: 0 1px 3px var(--color-shadow);
4552
- `;function ud({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:s}){const[i,u]=a.useState(!1),[f,c]=a.useState(),h=a.useRef(null),l=a.useRef(null),p={channels:o,organization_ids:n,workspace_ids:s,limit:20},{unreadCount:g,notifications:x,loading:m,markAsRead:b,markAllAsRead:$,deleteNotification:z}=Sc(p);return a.useEffect(()=>{if(!i)return;const w=setTimeout(()=>{const y=k=>{var _,v;const C=k.target;(_=h.current)!=null&&_.contains(C)||(v=l.current)!=null&&v.contains(C)||u(!1)};return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},50);return()=>{clearTimeout(w)}},[i]),a.useEffect(()=>{if(i&&h.current){const w=h.current.getBoundingClientRect(),y=400,k=600,C=window.innerWidth,_=window.innerHeight,v=C-w.left,P=_-w.bottom,I=w.top;let S,T;v>=y?S=w.left:T=C-w.right;let E,j;P>=k+8?E=w.bottom+8:I>=k+8?j=_-w.top+8:E=w.bottom+8,c({top:E,bottom:j,left:S,right:T})}else c(void 0)},[i]),e.jsx(ge,{children:e.jsxs(r1,{ref:h,className:t,children:[e.jsx(o1,{children:e.jsxs(n1,{onClick:()=>u(!i),children:[e.jsx(Up,{size:16}),r&&g>0&&e.jsx(s1,{children:g>9?"9+":g})]})}),typeof window<"u"&&i&&Wr.createPortal(e.jsx(ge,{children:e.jsx(dd,{ref:l,position:f,notifications:x,loading:m,onMarkAsRead:b,onMarkAllAsRead:$,onDelete:z})}),document.body)]})})}const i1=d.div`
4552
+ `;function ud({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:s}){const[a,p]=i.useState(!1),[f,c]=i.useState(),h=i.useRef(null),l=i.useRef(null),u={channels:o,organization_ids:n,workspace_ids:s,limit:20},{unreadCount:g,notifications:v,loading:x,markAsRead:w,markAllAsRead:$,deleteNotification:S}=Sc(u);return i.useEffect(()=>{if(!a)return;const k=setTimeout(()=>{const P=E=>{var y,m;const z=E.target;(y=h.current)!=null&&y.contains(z)||(m=l.current)!=null&&m.contains(z)||p(!1)};return document.addEventListener("mousedown",P),()=>{document.removeEventListener("mousedown",P)}},50);return()=>{clearTimeout(k)}},[a]),i.useEffect(()=>{if(a&&h.current){const k=h.current.getBoundingClientRect(),P=400,E=600,z=window.innerWidth,y=window.innerHeight,m=z-k.left,b=y-k.bottom,_=k.top;let j,T;m>=P?j=k.left:T=z-k.right;let R,C;b>=E+8?R=k.bottom+8:_>=E+8?C=y-k.top+8:R=k.bottom+8,c({top:R,bottom:C,left:j,right:T})}else c(void 0)},[a]),e.jsx(ge,{children:e.jsxs(r1,{ref:h,className:t,children:[e.jsx(o1,{children:e.jsxs(n1,{onClick:()=>p(!a),children:[e.jsx(Up,{size:16}),r&&g>0&&e.jsx(s1,{children:g>9?"9+":g})]})}),typeof window<"u"&&a&&Wr.createPortal(e.jsx(ge,{children:e.jsx(dd,{ref:l,position:f,notifications:v,loading:x,onMarkAsRead:w,onMarkAllAsRead:$,onDelete:S})}),document.body)]})})}const a1=d.div`
4553
4553
  display: flex;
4554
4554
  align-items: center;
4555
4555
  gap: 8px;
4556
- `,a1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(i1,{children:[r&&e.jsx(ud,{}),e.jsx(Ds,{showName:t})]}),c1=({children:t})=>{var i;const{session:r,loading:o}=Ue(),{deployment:n}=ve(),{navigateToAccountSelection:s}=Ge();return a.useEffect(()=>{var u;o||(u=r==null?void 0:r.signins)!=null&&u.length&&!r.active_signin&&s()},[o,r,n,s]),o||!((i=r.signins)!=null&&i.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},l1=({children:t})=>{var n;const{loading:r,session:o}=Ue();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},pd=ir`
4556
+ `,i1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(a1,{children:[r&&e.jsx(ud,{}),e.jsx(Ds,{showName:t})]}),c1=({children:t})=>{var a;const{session:r,loading:o}=Ue(),{deployment:n}=ve(),{navigateToAccountSelection:s}=Ge();return i.useEffect(()=>{var p;o||(p=r==null?void 0:r.signins)!=null&&p.length&&!r.active_signin&&s()},[o,r,n,s]),o||!((a=r.signins)!=null&&a.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},l1=({children:t})=>{var n;const{loading:r,session:o}=Ue();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},pd=ar`
4557
4557
  0% {
4558
4558
  background-position: -1000px 0;
4559
4559
  }
4560
4560
  100% {
4561
4561
  background-position: 1000px 0;
4562
4562
  }
4563
- `,d1=ir`
4563
+ `,d1=ar`
4564
4564
  from {
4565
4565
  transform: rotate(0deg);
4566
4566
  }
4567
4567
  to {
4568
4568
  transform: rotate(360deg);
4569
4569
  }
4570
- `,Da=d.div`
4570
+ `,Di=d.div`
4571
4571
  width: 400px;
4572
4572
  max-width: 100vw;
4573
4573
  padding: var(--space-3xl) var(--space-sm);
4574
4574
  background: var(--color-background);
4575
4575
  border-radius: var(--radius-lg);
4576
4576
  box-shadow: 0 4px 12px var(--color-shadow);
4577
- `,Na=d.div`
4577
+ `,Ni=d.div`
4578
4578
  margin: var(--space-lg) 0;
4579
4579
  border-top: 1px solid var(--color-border);
4580
4580
  border-bottom: 1px solid var(--color-border);
4581
4581
  overflow: hidden;
4582
- `,Fa=d.div`
4582
+ `,Fi=d.div`
4583
4583
  text-align: center;
4584
4584
  margin-bottom: var(--space-xl);
4585
- `,Ba=d.h1`
4585
+ `,Bi=d.h1`
4586
4586
  font-size: var(--font-lg);
4587
4587
  font-weight: 400;
4588
4588
  color: var(--color-foreground);
4589
4589
  margin-bottom: var(--space-xs);
4590
4590
  margin-top: 0;
4591
- `,Ua=d.p`
4591
+ `,Ui=d.p`
4592
4592
  color: var(--color-secondary-text);
4593
4593
  font-size: var(--font-xs);
4594
4594
  `,u1=d.div`
@@ -4755,7 +4755,7 @@ cursor: pointer;
4755
4755
  display: flex;
4756
4756
  flex-direction: column;
4757
4757
  gap: var(--space-xs);
4758
- `,Wa=d.div`
4758
+ `,Wi=d.div`
4759
4759
  height: ${t=>t.$width==="small"?"12px":"14px"};
4760
4760
  width: ${t=>t.$width==="small"?"60%":"40%"};
4761
4761
  border-radius: var(--radius-xs);
@@ -4782,7 +4782,7 @@ cursor: pointer;
4782
4782
  &:hover {
4783
4783
  color: var(--color-primary-hover);
4784
4784
  }
4785
- `,_1=({onAccountSelect:t,showAddAccount:r=!0})=>{var k,C,_,v,P;const{session:o,loading:n,switchSignIn:s,signOut:i}=Ue(),{deployment:u}=ve(),{navigateToSignIn:f,navigate:c}=Ge(),[h,l]=a.useState(null),[p,g]=a.useState(null),x=o==null?void 0:o.active_signin,m=(o==null?void 0:o.signins)||[],b=((C=(k=u==null?void 0:u.auth_settings)==null?void 0:k.multi_session_support)==null?void 0:C.enabled)??!1;a.useEffect(()=>{n||m.length||f()},[n,m,f]);const $=I=>I.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2),z=async I=>{var S;if(!(I===(x==null?void 0:x.id)||p)){g(I);try{if(await s(I),t)t(I),g(null);else{let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=(S=u.ui_settings)==null?void 0:S.after_signin_redirect_url),T){let E;try{E=new URL(T)}catch{E=new URL(T,window.location.origin)}(u==null?void 0:u.mode)==="staging"&&E.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(E.toString())}else g(null)}}catch(T){console.error("Failed to switch account:",T),g(null)}}},w=async(I,S)=>{I.stopPropagation(),l(S);try{await i(S)}catch(T){console.error("Failed to sign out:",T)}finally{l(null)}},y=()=>{var S;let I=new URLSearchParams(window.location.search).get("redirect_uri");I||(I=(S=u.ui_settings)==null?void 0:S.after_signin_redirect_url),f(I)};return n?e.jsx(ge,{children:e.jsxs(Da,{children:[e.jsx(Pe,{}),e.jsxs(Fa,{children:[e.jsx(Ba,{children:"Choose an account"}),e.jsxs(Ua,{children:["to continue to ",((_=u==null?void 0:u.ui_settings)==null?void 0:_.app_name)||"App"]})]}),e.jsx(Na,{children:[1,2].map(I=>e.jsxs(v1,{children:[e.jsx(b1,{}),e.jsxs(y1,{children:[e.jsx(Wa,{}),e.jsx(Wa,{$width:"small"})]})]},I))})]})}):m.length?e.jsx(ge,{children:e.jsxs(Da,{children:[e.jsx(Pe,{}),e.jsxs(Fa,{children:[e.jsx(Ba,{children:"Choose an account"}),e.jsxs(Ua,{children:["to continue to ",(v=u==null?void 0:u.ui_settings)==null?void 0:v.app_name]})]}),e.jsxs(Na,{children:[m.map(({user:I,id:S})=>{var R,M,F,A,B;if(!I)return null;const T=S===(x==null?void 0:x.id),E=p===S,j=`${I.first_name||""} ${I.last_name||""}`.trim();return e.jsxs(u1,{$isActive:T,$isSwitching:E,onClick:()=>z(S),children:[e.jsx(p1,{children:I.has_profile_picture?e.jsx("img",{src:I.profile_picture_url,alt:j}):$(j||((R=I.primary_email_address)==null?void 0:R.email)||((M=I.primary_phone_number)==null?void 0:M.phone_number)||I.username||"U")}),e.jsxs(h1,{children:[e.jsx(f1,{children:j||((F=I.primary_email_address)==null?void 0:F.email)||((A=I.primary_phone_number)==null?void 0:A.phone_number)||I.username||"User"}),e.jsx(g1,{children:((B=I.primary_email_address)==null?void 0:B.email)||I.username})]}),!E&&e.jsxs(m1,{onClick:O=>w(O,S),$isLoading:h===S,disabled:h===S,children:[h===S?e.jsx(kt,{size:12}):e.jsx(It,{size:12}),h===S?"Signing out...":"Sign out"]})]},S)}),r&&b&&e.jsxs(x1,{onClick:y,children:[e.jsx(Ke,{}),"Add another account"]})]}),e.jsxs(w1,{children:["Don't have an account?"," ",e.jsx(j1,{children:e.jsx(ot,{to:`${(P=u.ui_settings)==null?void 0:P.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},k1=()=>{const{navigateToSignIn:t}=Ge();return a.useEffect(()=>{t()},[t]),null},C1=()=>{const{navigateToSignUp:t}=Ge();return a.useEffect(()=>{t()},[t]),null},S1=d.div`
4785
+ `,_1=({onAccountSelect:t,showAddAccount:r=!0})=>{var E,z,y,m,b;const{session:o,loading:n,switchSignIn:s,signOut:a}=Ue(),{deployment:p}=ve(),{navigateToSignIn:f,navigate:c}=Ge(),[h,l]=i.useState(null),[u,g]=i.useState(null),v=o==null?void 0:o.active_signin,x=(o==null?void 0:o.signins)||[],w=((z=(E=p==null?void 0:p.auth_settings)==null?void 0:E.multi_session_support)==null?void 0:z.enabled)??!1;i.useEffect(()=>{n||x.length||f()},[n,x,f]);const $=_=>_.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),S=async _=>{var j;if(!(_===(v==null?void 0:v.id)||u)){g(_);try{if(await s(_),t)t(_),g(null);else{let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),T){let R;try{R=new URL(T)}catch{R=new URL(T,window.location.origin)}(p==null?void 0:p.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(R.toString())}else g(null)}}catch(T){console.error("Failed to switch account:",T),g(null)}}},k=async(_,j)=>{_.stopPropagation(),l(j);try{await a(j)}catch(T){console.error("Failed to sign out:",T)}finally{l(null)}},P=()=>{var j;let _=new URLSearchParams(window.location.search).get("redirect_uri");_||(_=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),f(_)};return n?e.jsx(ge,{children:e.jsxs(Di,{children:[e.jsx(Pe,{}),e.jsxs(Fi,{children:[e.jsx(Bi,{children:"Choose an account"}),e.jsxs(Ui,{children:["to continue to ",((y=p==null?void 0:p.ui_settings)==null?void 0:y.app_name)||"App"]})]}),e.jsx(Ni,{children:[1,2].map(_=>e.jsxs(v1,{children:[e.jsx(b1,{}),e.jsxs(y1,{children:[e.jsx(Wi,{}),e.jsx(Wi,{$width:"small"})]})]},_))})]})}):x.length?e.jsx(ge,{children:e.jsxs(Di,{children:[e.jsx(Pe,{}),e.jsxs(Fi,{children:[e.jsx(Bi,{children:"Choose an account"}),e.jsxs(Ui,{children:["to continue to ",(m=p==null?void 0:p.ui_settings)==null?void 0:m.app_name]})]}),e.jsxs(Ni,{children:[x.map(({user:_,id:j})=>{var I,M,F,L,B;if(!_)return null;const T=j===(v==null?void 0:v.id),R=u===j,C=`${_.first_name||""} ${_.last_name||""}`.trim();return e.jsxs(u1,{$isActive:T,$isSwitching:R,onClick:()=>S(j),children:[e.jsx(p1,{children:_.has_profile_picture?e.jsx("img",{src:_.profile_picture_url,alt:C}):$(C||((I=_.primary_email_address)==null?void 0:I.email)||((M=_.primary_phone_number)==null?void 0:M.phone_number)||_.username||"U")}),e.jsxs(h1,{children:[e.jsx(f1,{children:C||((F=_.primary_email_address)==null?void 0:F.email)||((L=_.primary_phone_number)==null?void 0:L.phone_number)||_.username||"User"}),e.jsx(g1,{children:((B=_.primary_email_address)==null?void 0:B.email)||_.username})]}),!R&&e.jsxs(m1,{onClick:O=>k(O,j),$isLoading:h===j,disabled:h===j,children:[h===j?e.jsx(kt,{size:12}):e.jsx(Et,{size:12}),h===j?"Signing out...":"Sign out"]})]},j)}),r&&w&&e.jsxs(x1,{onClick:P,children:[e.jsx(Ke,{}),"Add another account"]})]}),e.jsxs(w1,{children:["Don't have an account?"," ",e.jsx(j1,{children:e.jsx(ot,{to:`${(b=p.ui_settings)==null?void 0:b.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},k1=()=>{const{navigateToSignIn:t}=Ge();return i.useEffect(()=>{t()},[t]),null},C1=()=>{const{navigateToSignUp:t}=Ge();return i.useEffect(()=>{t()},[t]),null},S1=d.div`
4786
4786
  width: 100%;
4787
4787
  height: 500px;
4788
4788
  background: var(--color-background);
@@ -4876,7 +4876,7 @@ cursor: pointer;
4876
4876
  background: var(--color-border);
4877
4877
  border-radius: 2px;
4878
4878
  }
4879
- `,Va=d.button`
4879
+ `,Vi=d.button`
4880
4880
  display: grid;
4881
4881
  grid-template-columns: auto 1fr auto;
4882
4882
  align-items: center;
@@ -4900,7 +4900,7 @@ cursor: pointer;
4900
4900
  cursor: not-allowed;
4901
4901
  opacity: 0.6;
4902
4902
  }
4903
- `,Ga=d.div`
4903
+ `,Gi=d.div`
4904
4904
  width: 40px;
4905
4905
  height: 40px;
4906
4906
  border-radius: var(--radius-md);
@@ -4914,21 +4914,21 @@ cursor: pointer;
4914
4914
  font-size: 14px;
4915
4915
  font-weight: 400;
4916
4916
  flex-shrink: 0;
4917
- `,Ha=d.img`
4917
+ `,Hi=d.img`
4918
4918
  width: 100%;
4919
4919
  height: 100%;
4920
4920
  object-fit: cover;
4921
- `,qa=d.div`
4921
+ `,qi=d.div`
4922
4922
  flex: 1;
4923
4923
  min-width: 0;
4924
- `,Ya=d.div`
4924
+ `,Yi=d.div`
4925
4925
  font-size: 15px;
4926
4926
  font-weight: 400;
4927
4927
  color: var(--color-foreground);
4928
4928
  overflow: hidden;
4929
4929
  text-overflow: ellipsis;
4930
4930
  white-space: nowrap;
4931
- `,Za=d.div`
4931
+ `,Zi=d.div`
4932
4932
  display: flex;
4933
4933
  align-items: center;
4934
4934
  gap: var(--space-xs);
@@ -4941,7 +4941,7 @@ cursor: pointer;
4941
4941
  width: 12px;
4942
4942
  height: 12px;
4943
4943
  }
4944
- `,Ka=d.div`
4944
+ `,Ki=d.div`
4945
4945
  color: var(--color-secondary-text);
4946
4946
  display: flex;
4947
4947
  align-items: center;
@@ -4950,7 +4950,7 @@ cursor: pointer;
4950
4950
  width: 16px;
4951
4951
  height: 16px;
4952
4952
  }
4953
- `,Qa=d.div`
4953
+ `,Qi=d.div`
4954
4954
  grid-column: 2 / -1;
4955
4955
  font-size: 12px;
4956
4956
  color: var(--color-warning, #b45309);
@@ -4965,7 +4965,7 @@ cursor: pointer;
4965
4965
  height: 14px;
4966
4966
  flex-shrink: 0;
4967
4967
  }
4968
- `,Xa=d.div`
4968
+ `,Xi=d.div`
4969
4969
  text-align: center;
4970
4970
  padding: 32px 16px;
4971
4971
  display: flex;
@@ -4975,7 +4975,7 @@ cursor: pointer;
4975
4975
  align-items: center;
4976
4976
  justify-content: center;
4977
4977
  color: var(--color-secondary-text);
4978
- `,Ja=d.div`
4978
+ `,Ji=d.div`
4979
4979
  font-size: 14px;
4980
4980
  font-weight: 400;
4981
4981
  color: var(--color-foreground);
@@ -4990,10 +4990,10 @@ cursor: pointer;
4990
4990
  margin: 0 auto;
4991
4991
  padding: 6px 16px;
4992
4992
  font-size: 13px;
4993
- `,L1=()=>{var T,E;const{organizationMemberships:t,refetch:r,loading:o}=Ct(),{workspaces:n}=St(),{switchOrganization:s,switchWorkspace:i}=Ue(),{deployment:u}=ve(),[f,c]=a.useState(null),[h,l]=a.useState("orgList"),[p,g]=a.useState(null),x=(u==null?void 0:u.b2b_settings.workspaces_enabled)??!1,m=(u==null?void 0:u.b2b_settings.allow_users_to_create_orgs)??!1,b=a.useRef(!1);a.useEffect(()=>{if(!(b.current||!t)){if(b.current=!0,t.length===0){l("createOrg");return}if(!x){l("orgList");return}if(!n||n.length===0){t[0]&&g(t[0].organization.id),l("createWorkspace");return}l("orgList")}},[t,n,x]),console.log("view mode",h,x);const $=j=>j.split(" ").map(R=>R[0]).join("").toUpperCase().slice(0,2),z=async j=>{if(x){g(j.id),l("workspaceList");return}c(j.id);try{await s(j.id)}finally{c(null)}},w=async j=>{c(j.id);try{await i(j.id)}finally{c(null)}},y=async j=>{await r(),x&&j&&(g(j.id),l("createWorkspace"))},k=()=>{},C=async()=>{g(null),l("orgList")},_=(T=t==null?void 0:t.find(j=>j.organization.id===p))==null?void 0:T.organization,v=p?n==null?void 0:n.filter(j=>j.organization.id===p):[];if(o)return null;if(h==="createOrg")return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:y,onCancel:()=>l("orgList")})});if(h==="createWorkspace"&&p)return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(Ts,{organizationId:p,onSuccess:k,onCancel:()=>l("workspaceList"),onCreateOrganization:()=>l("createOrg")})});const P=h==="workspaceList",I=P?"Select a workspace":"Select an organization",S=P?`Choose a workspace in ${(_==null?void 0:_.name)||""}`:`to continue to ${((E=u==null?void 0:u.ui_settings)==null?void 0:E.app_name)||"App"}`;return e.jsxs(S1,{children:[e.jsxs(z1,{children:[e.jsxs("div",{children:[e.jsx(Pe,{}),e.jsxs(T1,{children:[e.jsx(M1,{children:I}),e.jsx(O1,{children:S})]})]}),e.jsx(Ds,{showName:!0})]}),e.jsxs($1,{children:[e.jsxs(E1,{children:[e.jsxs(I1,{children:[e.jsx(P1,{children:P?"Workspaces":"Your organizations"}),P&&e.jsxs(R1,{onClick:C,children:[e.jsx(Gr,{}),"Go back"]})]}),e.jsx(A1,{children:P?e.jsx(e.Fragment,{children:v&&v.length>0?v.map(j=>{var M,F,A;const R=((M=j.eligibility_restriction)==null?void 0:M.type)!=="none"&&((F=j.eligibility_restriction)==null?void 0:F.type)!==void 0;return e.jsxs(Va,{onClick:()=>!R&&w(j),disabled:f===j.id||R,style:{opacity:R?.7:1},children:[e.jsx(Ga,{children:j.image_url?e.jsx(Ha,{src:j.image_url,alt:j.name}):$(j.name).charAt(0)}),e.jsxs(qa,{children:[e.jsx(Ya,{children:j.name}),e.jsxs(Za,{children:[e.jsx(Uo,{}),"Workspace"]})]}),e.jsx(Ka,{children:e.jsx(ms,{})}),R&&e.jsxs(Qa,{children:[e.jsx(ut,{size:14}),(A=j.eligibility_restriction)==null?void 0:A.message]})]},j.id)}):e.jsxs(Xa,{children:[e.jsx(Ja,{children:"No workspaces yet"}),e.jsxs(ec,{children:["Create your first workspace for"," ",(_==null?void 0:_.name)||"this organization"]}),e.jsxs(tc,{onClick:()=>l("createWorkspace"),children:[e.jsx(Ke,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(j=>{var ee,V,q;const R=j.organization,M=n==null?void 0:n.filter(te=>te.organization.id===R.id),F=(M==null?void 0:M.length)||0,A=R.member_count,B=j.roles[0].name,O=j.roles.length-1,L=O>0?`${B.charAt(0).toUpperCase()+B.slice(1)} +${O}`:B.charAt(0).toUpperCase()+B.slice(1),X=((ee=j.eligibility_restriction)==null?void 0:ee.type)!=="none"&&((V=j.eligibility_restriction)==null?void 0:V.type)!==void 0;return e.jsxs(Va,{onClick:()=>!X&&z(R),disabled:f===R.id||X,style:{opacity:X?.7:1},children:[e.jsx(Ga,{children:R.image_url?e.jsx(Ha,{src:R.image_url,alt:R.name}):$(R.name)}),e.jsxs(qa,{children:[e.jsx(Ya,{children:R.name}),e.jsx(Za,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Uo,{}),F," workspace",F!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(Gp,{}),L," • ",A," member",A!==1?"s":""]})})]}),e.jsx(Ka,{children:e.jsx(ms,{})}),X&&e.jsxs(Qa,{children:[e.jsx(ut,{size:14}),(q=j.eligibility_restriction)==null?void 0:q.message]})]},R.id)}):e.jsxs(Xa,{children:[e.jsx(Ja,{children:"No organizations yet"}),e.jsx(ec,{children:m?"Create your first organization to get started":"You don't have access to any organizations yet"}),m&&e.jsxs(tc,{onClick:()=>l("createOrg"),children:[e.jsx(Ke,{}),"Create organization"]})]})})]}),P&&v&&v.length>0&&e.jsxs(Q,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createWorkspace"),disabled:f!==null,children:[e.jsx(Ke,{size:12}),"Create new workspace"]}),!P&&t&&t.length>0&&m&&e.jsxs(Q,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createOrg"),disabled:f!==null,children:[e.jsx(Ke,{size:12}),"Create new organization"]})]})]})},D1=d(ke.Content)`
4993
+ `,L1=()=>{var T,R;const{organizationMemberships:t,refetch:r,loading:o}=Ct(),{workspaces:n}=Pt(),{switchOrganization:s,switchWorkspace:a}=Ue(),{deployment:p}=ve(),[f,c]=i.useState(null),[h,l]=i.useState("orgList"),[u,g]=i.useState(null),v=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,x=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,w=i.useRef(!1);i.useEffect(()=>{if(!(w.current||!t)){if(w.current=!0,t.length===0){l("createOrg");return}if(!v){l("orgList");return}if(!n||n.length===0){t[0]&&g(t[0].organization.id),l("createWorkspace");return}l("orgList")}},[t,n,v]),console.log("view mode",h,v);const $=C=>C.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),S=async C=>{if(v){g(C.id),l("workspaceList");return}c(C.id);try{await s(C.id)}finally{c(null)}},k=async C=>{c(C.id);try{await a(C.id)}finally{c(null)}},P=async C=>{await r(),v&&C&&(g(C.id),l("createWorkspace"))},E=()=>{},z=async()=>{g(null),l("orgList")},y=(T=t==null?void 0:t.find(C=>C.organization.id===u))==null?void 0:T.organization,m=u?n==null?void 0:n.filter(C=>C.organization.id===u):[];if(o)return null;if(h==="createOrg")return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:P,onCancel:()=>l("orgList")})});if(h==="createWorkspace"&&u)return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(Ts,{organizationId:u,onSuccess:E,onCancel:()=>l("workspaceList"),onCreateOrganization:()=>l("createOrg")})});const b=h==="workspaceList",_=b?"Select a workspace":"Select an organization",j=b?`Choose a workspace in ${(y==null?void 0:y.name)||""}`:`to continue to ${((R=p==null?void 0:p.ui_settings)==null?void 0:R.app_name)||"App"}`;return e.jsxs(S1,{children:[e.jsxs(z1,{children:[e.jsxs("div",{children:[e.jsx(Pe,{}),e.jsxs(T1,{children:[e.jsx(M1,{children:_}),e.jsx(O1,{children:j})]})]}),e.jsx(Ds,{showName:!0})]}),e.jsxs($1,{children:[e.jsxs(E1,{children:[e.jsxs(I1,{children:[e.jsx(P1,{children:b?"Workspaces":"Your organizations"}),b&&e.jsxs(R1,{onClick:z,children:[e.jsx(Gr,{}),"Go back"]})]}),e.jsx(A1,{children:b?e.jsx(e.Fragment,{children:m&&m.length>0?m.map(C=>{var M,F,L;const I=((M=C.eligibility_restriction)==null?void 0:M.type)!=="none"&&((F=C.eligibility_restriction)==null?void 0:F.type)!==void 0;return e.jsxs(Vi,{onClick:()=>!I&&k(C),disabled:f===C.id||I,style:{opacity:I?.7:1},children:[e.jsx(Gi,{children:C.image_url?e.jsx(Hi,{src:C.image_url,alt:C.name}):$(C.name).charAt(0)}),e.jsxs(qi,{children:[e.jsx(Yi,{children:C.name}),e.jsxs(Zi,{children:[e.jsx(Uo,{}),"Workspace"]})]}),e.jsx(Ki,{children:e.jsx(ms,{})}),I&&e.jsxs(Qi,{children:[e.jsx(ut,{size:14}),(L=C.eligibility_restriction)==null?void 0:L.message]})]},C.id)}):e.jsxs(Xi,{children:[e.jsx(Ji,{children:"No workspaces yet"}),e.jsxs(ec,{children:["Create your first workspace for"," ",(y==null?void 0:y.name)||"this organization"]}),e.jsxs(tc,{onClick:()=>l("createWorkspace"),children:[e.jsx(Ke,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(C=>{var te,V,q;const I=C.organization,M=n==null?void 0:n.filter(re=>re.organization.id===I.id),F=(M==null?void 0:M.length)||0,L=I.member_count,B=C.roles[0].name,O=C.roles.length-1,A=O>0?`${B.charAt(0).toUpperCase()+B.slice(1)} +${O}`:B.charAt(0).toUpperCase()+B.slice(1),X=((te=C.eligibility_restriction)==null?void 0:te.type)!=="none"&&((V=C.eligibility_restriction)==null?void 0:V.type)!==void 0;return e.jsxs(Vi,{onClick:()=>!X&&S(I),disabled:f===I.id||X,style:{opacity:X?.7:1},children:[e.jsx(Gi,{children:I.image_url?e.jsx(Hi,{src:I.image_url,alt:I.name}):$(I.name)}),e.jsxs(qi,{children:[e.jsx(Yi,{children:I.name}),e.jsx(Zi,{children:v?e.jsxs(e.Fragment,{children:[e.jsx(Uo,{}),F," workspace",F!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(Gp,{}),A," • ",L," member",L!==1?"s":""]})})]}),e.jsx(Ki,{children:e.jsx(ms,{})}),X&&e.jsxs(Qi,{children:[e.jsx(ut,{size:14}),(q=C.eligibility_restriction)==null?void 0:q.message]})]},I.id)}):e.jsxs(Xi,{children:[e.jsx(Ji,{children:"No organizations yet"}),e.jsx(ec,{children:x?"Create your first organization to get started":"You don't have access to any organizations yet"}),x&&e.jsxs(tc,{onClick:()=>l("createOrg"),children:[e.jsx(Ke,{}),"Create organization"]})]})})]}),b&&m&&m.length>0&&e.jsxs(Q,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createWorkspace"),disabled:f!==null,children:[e.jsx(Ke,{size:12}),"Create new workspace"]}),!b&&t&&t.length>0&&x&&e.jsxs(Q,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createOrg"),disabled:f!==null,children:[e.jsx(Ke,{size:12}),"Create new organization"]})]})]})},D1=d(ke.Content)`
4994
4994
  padding: 0;
4995
4995
  max-width: 90vw;
4996
- `,N1=({children:t})=>{var b,$,z,w;const{loading:r,session:o}=Ue(),{activeOrganization:n}=Ze(),{activeWorkspace:s,loading:i}=Rt(),{workspaces:u}=St(),{deployment:f}=ve(),{organizationMemberships:c}=Ct(),h=(f==null?void 0:f.b2b_settings.workspaces_enabled)??!1,l=c==null?void 0:c.find(y=>y.organization.id===(n==null?void 0:n.id)),p=u==null?void 0:u.find(y=>{var k;return y.id===((k=o==null?void 0:o.active_signin)==null?void 0:k.active_workspace_membership_id)}),g=((b=l==null?void 0:l.eligibility_restriction)==null?void 0:b.type)!=="none"&&(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!==void 0,x=((z=p==null?void 0:p.eligibility_restriction)==null?void 0:z.type)!=="none"&&((w=p==null?void 0:p.eligibility_restriction)==null?void 0:w.type)!==void 0;return r||h&&i?null:(g||x||!n?!1:h?s?u==null?void 0:u.some(k=>k.id===s.id&&k.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(ge,{children:e.jsx(ke,{isOpen:!0,children:e.jsx(ke.Overlay,{children:e.jsx(D1,{style:{width:"850px"},children:e.jsx(L1,{})})})})})},F1=d.div`
4996
+ `,N1=({children:t})=>{var w,$,S,k;const{loading:r,session:o}=Ue(),{activeOrganization:n}=Ze(),{activeWorkspace:s,loading:a}=Rt(),{workspaces:p}=Pt(),{deployment:f}=ve(),{organizationMemberships:c}=Ct(),h=(f==null?void 0:f.b2b_settings.workspaces_enabled)??!1,l=c==null?void 0:c.find(P=>P.organization.id===(n==null?void 0:n.id)),u=p==null?void 0:p.find(P=>{var E;return P.id===((E=o==null?void 0:o.active_signin)==null?void 0:E.active_workspace_membership_id)}),g=((w=l==null?void 0:l.eligibility_restriction)==null?void 0:w.type)!=="none"&&(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!==void 0,v=((S=u==null?void 0:u.eligibility_restriction)==null?void 0:S.type)!=="none"&&((k=u==null?void 0:u.eligibility_restriction)==null?void 0:k.type)!==void 0;return r||h&&a?null:(g||v||!n?!1:h?s?p==null?void 0:p.some(E=>E.id===s.id&&E.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(ge,{children:e.jsx(ke,{isOpen:!0,children:e.jsx(ke.Overlay,{children:e.jsx(D1,{style:{width:"850px"},children:e.jsx(L1,{})})})})})},F1=d.div`
4997
4997
  display: flex;
4998
4998
  gap: 8px;
4999
4999
  flex-wrap: wrap;
@@ -5021,7 +5021,7 @@ cursor: pointer;
5021
5021
  border-radius: 8px;
5022
5022
  font-size: 10px;
5023
5023
  font-weight: 400;
5024
- `,W1={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function V1({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=s=>{if(t.includes(s)){const u=t.filter(f=>f!==s);u.length===0?o(["user"]):o(u)}else o([...t,s])};return e.jsx(F1,{children:Object.entries(W1).map(([s,i])=>{const u=(r==null?void 0:r[s])||0,f=t.includes(s);return e.jsxs(B1,{$active:f,onClick:()=>n(s),children:[i,u>0&&e.jsx(U1,{children:u})]},s)})})}const rc=d.div`
5024
+ `,W1={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function V1({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=s=>{if(t.includes(s)){const p=t.filter(f=>f!==s);p.length===0?o(["user"]):o(p)}else o([...t,s])};return e.jsx(F1,{children:Object.entries(W1).map(([s,a])=>{const p=(r==null?void 0:r[s])||0,f=t.includes(s);return e.jsxs(B1,{$active:f,onClick:()=>n(s),children:[a,p>0&&e.jsx(U1,{children:p})]},s)})})}const rc=d.div`
5025
5025
  display: flex;
5026
5026
  flex-direction: column;
5027
5027
  width: 100%;
@@ -5372,12 +5372,12 @@ cursor: pointer;
5372
5372
  flex-direction: row;
5373
5373
  gap: 20px;
5374
5374
  }
5375
- `,ib=d.form`
5375
+ `,ab=d.form`
5376
5376
  padding: 20px;
5377
5377
  background: var(--color-background);
5378
5378
  border-top: 1px solid var(--color-border);
5379
5379
  flex-shrink: 0;
5380
- `,ab=d.div`
5380
+ `,ib=d.div`
5381
5381
  position: relative;
5382
5382
  display: flex;
5383
5383
  align-items: flex-end;
@@ -5675,7 +5675,7 @@ cursor: pointer;
5675
5675
  &:hover .expand-icon {
5676
5676
  opacity: 1;
5677
5677
  }
5678
- `,kb=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:s,onClose:i,onDownload:u,onZoom:f,onReset:c,onWheel:h,onMouseDown:l,onMouseMove:p,onMouseUp:g})=>{const[x,m]=a.useState(!1),b=a.useRef(null);return a.useEffect(()=>(m(!0),()=>m(!1)),[]),a.useEffect(()=>{if(t){const $=document.body.style.overflow;document.body.style.overflow="hidden";const z=k=>{(k.ctrlKey||k.metaKey)&&k.preventDefault()},w=k=>{k.preventDefault()},y=k=>{k.preventDefault()};return document.addEventListener("wheel",z,{passive:!1}),document.addEventListener("gesturestart",w,{passive:!1}),document.addEventListener("gesturechange",y,{passive:!1}),()=>{document.body.style.overflow=$,document.removeEventListener("wheel",z),document.removeEventListener("gesturestart",w),document.removeEventListener("gesturechange",y)}}},[t]),!x||!t||!r?null:Wr.createPortal(e.jsx(ge,{children:e.jsx(xb,{ref:b,$isOpen:!0,onClick:$=>{$.target===$.currentTarget&&i()},children:e.jsxs(vb,{onClick:$=>$.stopPropagation(),onWheel:$=>{$.preventDefault(),$.stopPropagation(),h($)},onMouseMove:p,onMouseUp:g,onMouseLeave:g,children:[e.jsx(bb,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:s,onMouseDown:l,draggable:!1}),e.jsx(Eo,{$variant:"ghost",onClick:i,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(et,{size:14})}),e.jsxs(yb,{children:[e.jsxs(wb,{children:[e.jsx(Eo,{$variant:"ghost",onClick:()=>f(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(Ah,{size:14})}),e.jsxs(jb,{children:[Math.round(o*100),"%"]}),e.jsx(Eo,{$variant:"ghost",onClick:()=>f(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Mh,{size:14})}),e.jsx(Eo,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(gh,{size:14})})]}),e.jsxs(fd,{$variant:"primary",onClick:u,title:"Download image",children:[e.jsx(rn,{size:14}),"Download"]})]})]})})}),document.body)};function gd({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:s,selectedSession:i,selectSession:u}=qo(),f=i==null?void 0:i.id;if(!f)return e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsx(rc,{children:e.jsxs(oc,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,h=!0,l="Start a conversation by typing a message below",[p,g]=a.useState(""),[x,m]=a.useState(!1),[b,$]=a.useState(null),[z,w]=a.useState([]),[y,k]=a.useState([]),[C,_]=a.useState(null),[v,P]=a.useState(1),[I,S]=a.useState(!1),[T,E]=a.useState({x:0,y:0}),[j,R]=a.useState({x:0,y:0}),M=a.useRef(null),F=a.useRef(null),{messages:A,pendingMessage:B,pendingImages:O,connectionState:L,isConnected:X,isExecuting:ee,executionStatus:V,isWaitingForInput:q,sendMessage:te,submitUserInput:re,cancelExecution:le}=zc({contextId:f,agentName:o,token:n,platformAdapter:s,autoConnect:c});a.useEffect(()=>{var N;(N=M.current)==null||N.scrollIntoView({behavior:"smooth"})},[A]),a.useEffect(()=>{var N;if(q){const D=A.slice().reverse().find(Y=>{var ie;return((ie=Y.metadata)==null?void 0:ie.type)==="user_input_request"});(N=D==null?void 0:D.metadata)!=null&&N.userInputRequest&&$(D.metadata.userInputRequest)}else $(null),w([])},[q,A]);const oe=N=>{if(N.preventDefault(),!!X)if(q&&b){let D=p.trim();b.input_type==="multiselect"&&(D=z.join(",")),D&&(re(D),g(""),w([]))}else!ee&&p.trim()&&(te(p,y.length>0?y:void 0),g(""),k([]))},de=N=>{const D=N.target.files;D&&(Array.from(D).forEach(Y=>{if(Y.type.startsWith("image/")){const ie=new FileReader;ie.onload=J=>{var _e;if((_e=J.target)!=null&&_e.result){const ze=J.target.result.split(",")[1];k(Ae=>[...Ae,{mime_type:Y.type,data:ze}])}},ie.readAsDataURL(Y)}}),F.current&&(F.current.value=""))},Z=N=>{k(D=>D.filter((Y,ie)=>ie!==N))},se=N=>{_(N),P(1),E({x:0,y:0})},xe=()=>{_(null),P(1),E({x:0,y:0}),S(!1)},ue=N=>{const D=document.createElement("a");D.href=N,D.download=`image-${Date.now()}.png`,document.body.appendChild(D),D.click(),document.body.removeChild(D)},U=N=>{P(D=>{const Y=D+N;return Math.min(Math.max(Y,.5),3)})},pe=N=>{N.preventDefault(),N.stopPropagation();const D=N.deltaY>0?-.1:.1;U(D)},K=N=>{v>1&&(S(!0),R({x:N.clientX-T.x,y:N.clientY-T.y}))},H=N=>{I&&v>1&&E({x:N.clientX-j.x,y:N.clientY-j.y})},ne=()=>{S(!1)},me=()=>L.status===wt.CONNECTING?"Connecting...":L.status===wt.ERROR?"Connection error":L.status===wt.DISCONNECTED||!X?"Disconnected":q?"Waiting for your input...":ee?"Working...":"Ready",fe=()=>{if(!q||!b)return"Ask anything";switch(b.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},W=()=>!q||!b?!1:["select","multiselect","boolean","date"].includes(b.input_type||"");return e.jsxs(ge,{style:{height:"100%",width:"100%"},children:[e.jsxs(rc,{children:[e.jsxs(G1,{children:[e.jsxs(H1,{children:[t&&e.jsx(q1,{onClick:()=>{r?r():u(null)},children:e.jsx(Gr,{size:20})}),e.jsxs(Y1,{children:[e.jsx(Z1,{children:e.jsx(wn,{size:20})}),e.jsxs(K1,{children:[e.jsx(X1,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Q1,{$status:me()}),e.jsx(J1,{$status:me(),children:me()})]})]})]})]}),V!==Le.IDLE&&e.jsx(eb,{$status:V,children:V.replace("_"," ")})]}),e.jsx(tb,{children:A.length===0&&h?e.jsxs(oc,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:l})]}):e.jsxs(e.Fragment,{children:[A.map((N,D)=>{var Y,ie,J,_e;if(((Y=N.metadata)==null?void 0:Y.type)==="user_input_request"&&N.metadata.userInputRequest){const be=N.metadata.userInputRequest,ze=!be.input_type||be.input_type==="text"||be.input_type==="number",Ae=q&&(b==null?void 0:b.input_type)===be.input_type;return e.jsx(Zn,{$isUser:!1,children:e.jsxs(sb,{children:[e.jsx("div",{className:"question",children:be.question}),be.context&&be.context.trim()&&e.jsx("div",{className:"context",children:be.context}),!ze&&e.jsxs("div",{className:"controls",children:[be.input_type==="select"&&be.options&&e.jsxs("select",{value:Ae?p:"",onChange:Re=>g(Re.target.value),disabled:!Ae,children:[e.jsx("option",{value:"",children:"Choose an option..."}),be.options.map(Re=>e.jsx("option",{value:Re,children:Re},Re))]}),be.input_type==="multiselect"&&be.options&&e.jsx("div",{className:"checkbox-group",children:be.options.map(Re=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Ae&&z.includes(Re),onChange:ar=>{ar.target.checked?w([...z,Re]):w(z.filter(cr=>cr!==Re))},disabled:!Ae}),e.jsx("span",{children:Re})]},Re))}),be.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Ae&&p==="true",onChange:Re=>g(Re.target.value),disabled:!Ae}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Ae&&p==="false",onChange:Re=>g(Re.target.value),disabled:!Ae}),e.jsx("span",{children:"No"})]})]}),be.input_type==="date"&&e.jsx("input",{type:"date",value:Ae?p:"",onChange:Re=>g(Re.target.value),disabled:!Ae})]}),e.jsx("div",{className:"instruction",children:Ae?ze?"Type your response below":be.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},N.id)}if(((ie=N.metadata)==null?void 0:ie.type)==="log"){const be=A[D-1],ze=A[D+1],Ae=((J=be==null?void 0:be.metadata)==null?void 0:J.type)==="log",Re=((_e=ze==null?void 0:ze.metadata)==null?void 0:_e.type)==="log",ar=Ae||Re,cr=!Ae&&Re,Zr=Ae&&!Re;return e.jsx(nb,{$isGrouped:ar,$isFirstInGroup:cr,$isLastInGroup:Zr,children:e.jsx("div",{className:"log-content",children:N.content})},N.id)}return!N.content&&(!N.images||N.images.length===0)?null:e.jsx(Zn,{$isUser:N.role==="user",children:e.jsxs(hd,{$isUser:N.role==="user",children:[e.jsx("div",{children:N.content}),N.images&&N.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:N.images.map((be,ze)=>{const Ae=be.url||`data:${be.mime_type};base64,${be.data}`;return e.jsxs(_b,{onClick:()=>se(Ae),title:"Click to preview",children:[e.jsx("img",{src:Ae,alt:`Image ${ze+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(oh,{size:14})})]},ze)})}),N.isStreaming&&e.jsx(rb,{})]})},N.id)}),B&&e.jsx(Zn,{$isUser:!0,children:e.jsxs(ob,{$isUser:!0,children:[e.jsx("div",{children:B}),O&&O.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:O.map((N,D)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:N.data?`data:${N.mime_type};base64,${N.data}`:"#",alt:`Image ${D+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},D))})]})}),e.jsx("div",{ref:M})]})}),y.length>0&&e.jsx(ub,{children:y.map((N,D)=>e.jsxs(pb,{children:[e.jsx("img",{src:N.data?`data:${N.mime_type};base64,${N.data}`:"#",alt:`Upload ${D+1}`}),e.jsx(hb,{type:"button",onClick:()=>Z(D),children:e.jsx(et,{size:12})})]},D))}),e.jsx(ib,{onSubmit:oe,children:e.jsxs(ab,{children:[e.jsxs(cb,{children:[e.jsx(lb,{value:p,onChange:N=>g(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),oe(N))},placeholder:fe(),disabled:!X||ee&&!q||W(),rows:1}),e.jsx(db,{children:e.jsxs(gb,{type:"button",disabled:!X||ee,onClick:()=>{var N;return(N=F.current)==null?void 0:N.click()},children:[e.jsx(vh,{size:16}),"Attach"]})}),e.jsx(fb,{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:de})]}),e.jsx(mb,{type:ee?"button":"submit",disabled:!X||!q&&!ee&&!p.trim(),onClick:ee?le:void 0,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{background:ee&&x?"var(--color-error)":void 0},children:ee?x?e.jsx(et,{size:14}):e.jsx(kt,{size:14,className:"animate-spin"}):e.jsx($s,{size:14})})]})})]}),e.jsx(kb,{isOpen:!!C,imageUrl:C,zoomLevel:v,dragPosition:T,isDragging:I,onClose:xe,onDownload:()=>C&&ue(C),onZoom:U,onReset:()=>{P(1),E({x:0,y:0})},onWheel:pe,onMouseDown:K,onMouseMove:H,onMouseUp:ne})]})}const Cb=d.div`
5678
+ `,kb=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:s,onClose:a,onDownload:p,onZoom:f,onReset:c,onWheel:h,onMouseDown:l,onMouseMove:u,onMouseUp:g})=>{const[v,x]=i.useState(!1),w=i.useRef(null);return i.useEffect(()=>(x(!0),()=>x(!1)),[]),i.useEffect(()=>{if(t){const $=document.body.style.overflow;document.body.style.overflow="hidden";const S=E=>{(E.ctrlKey||E.metaKey)&&E.preventDefault()},k=E=>{E.preventDefault()},P=E=>{E.preventDefault()};return document.addEventListener("wheel",S,{passive:!1}),document.addEventListener("gesturestart",k,{passive:!1}),document.addEventListener("gesturechange",P,{passive:!1}),()=>{document.body.style.overflow=$,document.removeEventListener("wheel",S),document.removeEventListener("gesturestart",k),document.removeEventListener("gesturechange",P)}}},[t]),!v||!t||!r?null:Wr.createPortal(e.jsx(ge,{children:e.jsx(xb,{ref:w,$isOpen:!0,onClick:$=>{$.target===$.currentTarget&&a()},children:e.jsxs(vb,{onClick:$=>$.stopPropagation(),onWheel:$=>{$.preventDefault(),$.stopPropagation(),h($)},onMouseMove:u,onMouseUp:g,onMouseLeave:g,children:[e.jsx(bb,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:s,onMouseDown:l,draggable:!1}),e.jsx(Eo,{$variant:"ghost",onClick:a,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(et,{size:14})}),e.jsxs(yb,{children:[e.jsxs(wb,{children:[e.jsx(Eo,{$variant:"ghost",onClick:()=>f(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(Ah,{size:14})}),e.jsxs(jb,{children:[Math.round(o*100),"%"]}),e.jsx(Eo,{$variant:"ghost",onClick:()=>f(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Mh,{size:14})}),e.jsx(Eo,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(gh,{size:14})})]}),e.jsxs(fd,{$variant:"primary",onClick:p,title:"Download image",children:[e.jsx(rn,{size:14}),"Download"]})]})]})})}),document.body)};function gd({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:s,selectedSession:a,selectSession:p}=qo(),f=a==null?void 0:a.id;if(!f)return e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsx(rc,{children:e.jsxs(oc,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,h=!0,l="Start a conversation by typing a message below",[u,g]=i.useState(""),[v,x]=i.useState(!1),[w,$]=i.useState(null),[S,k]=i.useState([]),[P,E]=i.useState([]),[z,y]=i.useState(null),[m,b]=i.useState(1),[_,j]=i.useState(!1),[T,R]=i.useState({x:0,y:0}),[C,I]=i.useState({x:0,y:0}),M=i.useRef(null),F=i.useRef(null),{messages:L,pendingMessage:B,pendingImages:O,connectionState:A,isConnected:X,isExecuting:te,executionStatus:V,isWaitingForInput:q,sendMessage:re,submitUserInput:ne,cancelExecution:J}=zc({contextId:f,agentName:o,token:n,platformAdapter:s,autoConnect:c});i.useEffect(()=>{var N;(N=M.current)==null||N.scrollIntoView({behavior:"smooth"})},[L]),i.useEffect(()=>{var N;if(q){const D=L.slice().reverse().find(Y=>{var ie;return((ie=Y.metadata)==null?void 0:ie.type)==="user_input_request"});(N=D==null?void 0:D.metadata)!=null&&N.userInputRequest&&$(D.metadata.userInputRequest)}else $(null),k([])},[q,L]);const oe=N=>{if(N.preventDefault(),!!X)if(q&&w){let D=u.trim();w.input_type==="multiselect"&&(D=S.join(",")),D&&(ne(D),g(""),k([]))}else!te&&u.trim()&&(re(u,P.length>0?P:void 0),g(""),E([]))},de=N=>{const D=N.target.files;D&&(Array.from(D).forEach(Y=>{if(Y.type.startsWith("image/")){const ie=new FileReader;ie.onload=ee=>{var _e;if((_e=ee.target)!=null&&_e.result){const ze=ee.target.result.split(",")[1];E(Ae=>[...Ae,{mime_type:Y.type,data:ze}])}},ie.readAsDataURL(Y)}}),F.current&&(F.current.value=""))},Z=N=>{E(D=>D.filter((Y,ie)=>ie!==N))},ae=N=>{y(N),b(1),R({x:0,y:0})},xe=()=>{y(null),b(1),R({x:0,y:0}),j(!1)},ue=N=>{const D=document.createElement("a");D.href=N,D.download=`image-${Date.now()}.png`,document.body.appendChild(D),D.click(),document.body.removeChild(D)},U=N=>{b(D=>{const Y=D+N;return Math.min(Math.max(Y,.5),3)})},pe=N=>{N.preventDefault(),N.stopPropagation();const D=N.deltaY>0?-.1:.1;U(D)},K=N=>{m>1&&(j(!0),I({x:N.clientX-T.x,y:N.clientY-T.y}))},H=N=>{_&&m>1&&R({x:N.clientX-C.x,y:N.clientY-C.y})},se=()=>{j(!1)},me=()=>A.status===wt.CONNECTING?"Connecting...":A.status===wt.ERROR?"Connection error":A.status===wt.DISCONNECTED||!X?"Disconnected":q?"Waiting for your input...":te?"Working...":"Ready",fe=()=>{if(!q||!w)return"Ask anything";switch(w.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},W=()=>!q||!w?!1:["select","multiselect","boolean","date"].includes(w.input_type||"");return e.jsxs(ge,{style:{height:"100%",width:"100%"},children:[e.jsxs(rc,{children:[e.jsxs(G1,{children:[e.jsxs(H1,{children:[t&&e.jsx(q1,{onClick:()=>{r?r():p(null)},children:e.jsx(Gr,{size:20})}),e.jsxs(Y1,{children:[e.jsx(Z1,{children:e.jsx(wn,{size:20})}),e.jsxs(K1,{children:[e.jsx(X1,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Q1,{$status:me()}),e.jsx(J1,{$status:me(),children:me()})]})]})]})]}),V!==Le.IDLE&&e.jsx(eb,{$status:V,children:V.replace("_"," ")})]}),e.jsx(tb,{children:L.length===0&&h?e.jsxs(oc,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:l})]}):e.jsxs(e.Fragment,{children:[L.map((N,D)=>{var Y,ie,ee,_e;if(((Y=N.metadata)==null?void 0:Y.type)==="user_input_request"&&N.metadata.userInputRequest){const be=N.metadata.userInputRequest,ze=!be.input_type||be.input_type==="text"||be.input_type==="number",Ae=q&&(w==null?void 0:w.input_type)===be.input_type;return e.jsx(Zn,{$isUser:!1,children:e.jsxs(sb,{children:[e.jsx("div",{className:"question",children:be.question}),be.context&&be.context.trim()&&e.jsx("div",{className:"context",children:be.context}),!ze&&e.jsxs("div",{className:"controls",children:[be.input_type==="select"&&be.options&&e.jsxs("select",{value:Ae?u:"",onChange:Re=>g(Re.target.value),disabled:!Ae,children:[e.jsx("option",{value:"",children:"Choose an option..."}),be.options.map(Re=>e.jsx("option",{value:Re,children:Re},Re))]}),be.input_type==="multiselect"&&be.options&&e.jsx("div",{className:"checkbox-group",children:be.options.map(Re=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Ae&&S.includes(Re),onChange:ir=>{ir.target.checked?k([...S,Re]):k(S.filter(cr=>cr!==Re))},disabled:!Ae}),e.jsx("span",{children:Re})]},Re))}),be.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Ae&&u==="true",onChange:Re=>g(Re.target.value),disabled:!Ae}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Ae&&u==="false",onChange:Re=>g(Re.target.value),disabled:!Ae}),e.jsx("span",{children:"No"})]})]}),be.input_type==="date"&&e.jsx("input",{type:"date",value:Ae?u:"",onChange:Re=>g(Re.target.value),disabled:!Ae})]}),e.jsx("div",{className:"instruction",children:Ae?ze?"Type your response below":be.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},N.id)}if(((ie=N.metadata)==null?void 0:ie.type)==="log"){const be=L[D-1],ze=L[D+1],Ae=((ee=be==null?void 0:be.metadata)==null?void 0:ee.type)==="log",Re=((_e=ze==null?void 0:ze.metadata)==null?void 0:_e.type)==="log",ir=Ae||Re,cr=!Ae&&Re,Zr=Ae&&!Re;return e.jsx(nb,{$isGrouped:ir,$isFirstInGroup:cr,$isLastInGroup:Zr,children:e.jsx("div",{className:"log-content",children:N.content})},N.id)}return!N.content&&(!N.images||N.images.length===0)?null:e.jsx(Zn,{$isUser:N.role==="user",children:e.jsxs(hd,{$isUser:N.role==="user",children:[e.jsx("div",{children:N.content}),N.images&&N.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:N.images.map((be,ze)=>{const Ae=be.url||`data:${be.mime_type};base64,${be.data}`;return e.jsxs(_b,{onClick:()=>ae(Ae),title:"Click to preview",children:[e.jsx("img",{src:Ae,alt:`Image ${ze+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(oh,{size:14})})]},ze)})}),N.isStreaming&&e.jsx(rb,{})]})},N.id)}),B&&e.jsx(Zn,{$isUser:!0,children:e.jsxs(ob,{$isUser:!0,children:[e.jsx("div",{children:B}),O&&O.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:O.map((N,D)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:N.data?`data:${N.mime_type};base64,${N.data}`:"#",alt:`Image ${D+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},D))})]})}),e.jsx("div",{ref:M})]})}),P.length>0&&e.jsx(ub,{children:P.map((N,D)=>e.jsxs(pb,{children:[e.jsx("img",{src:N.data?`data:${N.mime_type};base64,${N.data}`:"#",alt:`Upload ${D+1}`}),e.jsx(hb,{type:"button",onClick:()=>Z(D),children:e.jsx(et,{size:12})})]},D))}),e.jsx(ab,{onSubmit:oe,children:e.jsxs(ib,{children:[e.jsxs(cb,{children:[e.jsx(lb,{value:u,onChange:N=>g(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),oe(N))},placeholder:fe(),disabled:!X||te&&!q||W(),rows:1}),e.jsx(db,{children:e.jsxs(gb,{type:"button",disabled:!X||te,onClick:()=>{var N;return(N=F.current)==null?void 0:N.click()},children:[e.jsx(vh,{size:16}),"Attach"]})}),e.jsx(fb,{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:de})]}),e.jsx(mb,{type:te?"button":"submit",disabled:!X||!q&&!te&&!u.trim(),onClick:te?J:void 0,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),style:{background:te&&v?"var(--color-error)":void 0},children:te?v?e.jsx(et,{size:14}):e.jsx(kt,{size:14,className:"animate-spin"}):e.jsx($s,{size:14})})]})})]}),e.jsx(kb,{isOpen:!!z,imageUrl:z,zoomLevel:m,dragPosition:T,isDragging:_,onClose:xe,onDownload:()=>z&&ue(z),onZoom:U,onReset:()=>{b(1),R({x:0,y:0})},onWheel:pe,onMouseDown:K,onMouseMove:H,onMouseUp:se})]})}const Cb=d.div`
5679
5679
  height: 100%;
5680
5680
  display: flex;
5681
5681
  flex-direction: column;
@@ -5870,7 +5870,7 @@ cursor: pointer;
5870
5870
  background: var(--color-border);
5871
5871
  border-radius: var(--radius-sm);
5872
5872
  opacity: 0.6;
5873
- `;function md({showBackButton:t=!1}){const[r,o]=a.useState(""),{sessions:n,loadingSessions:s,selectSession:i,deleteSession:u,setShowHistory:f}=qo(),c=n.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())),h=x=>{const m={},b=new Date,$=new Date(b.getFullYear(),b.getMonth(),b.getDate()),z=new Date($);z.setDate(z.getDate()-1);const w=new Date($);return w.setDate(w.getDate()-7),x.forEach(y=>{const k=new Date(y.last_activity_at);let C;k>=$?C="Today":k>=z?C="Yesterday":k>=w?C="This Week":C="Older",m[C]||(m[C]=[]),m[C].push(y)}),m},l=async(x,m)=>{if(x.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await u(m)}catch(b){console.error("Failed to delete session:",b)}},p=x=>new Date(x).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),g=h(c);return e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsxs(Cb,{children:[e.jsxs(Sb,{children:[t&&e.jsx(zb,{onClick:()=>f(!1),children:e.jsx(Gr,{size:20})}),e.jsx($b,{children:"Conversation History"})]}),e.jsx(Eb,{children:e.jsx(Ib,{type:"text",placeholder:"Search conversations...",value:r,onChange:x=>o(x.target.value)})}),e.jsx(Pb,{children:s?e.jsx(Ub,{children:[1,2,3,4,5].map(x=>e.jsxs(Wb,{children:[e.jsx(Vb,{}),e.jsxs(Gb,{children:[e.jsx(Hb,{}),e.jsx(qb,{})]})]},x))}):c.length===0?e.jsxs(Bb,{children:[e.jsx(fi,{}),e.jsx("div",{children:"No conversations found"}),r&&e.jsx("div",{style:{fontSize:"var(--font-xs)",marginTop:"var(--space-sm)"},children:"Try a different search term"})]}):Object.entries(g).map(([x,m])=>e.jsxs(Rb,{children:[e.jsx(Tb,{children:x}),m.map(b=>e.jsxs(Mb,{onClick:()=>i(b),children:[e.jsx(Ob,{children:e.jsx(fi,{size:18})}),e.jsxs(Ab,{children:[e.jsx(Lb,{children:b.title}),e.jsxs(Db,{children:[e.jsx("span",{children:p(b.last_activity_at)}),b.status!=="idle"&&e.jsx(Nb,{$status:b.status,children:b.status.replace("_"," ")})]})]}),e.jsx(Fb,{onClick:$=>l($,b.id),children:e.jsx(nn,{size:16})})]},b.id))]},x))})]})})}const Yb=d.div`
5873
+ `;function md({showBackButton:t=!1}){const[r,o]=i.useState(""),{sessions:n,loadingSessions:s,selectSession:a,deleteSession:p,setShowHistory:f}=qo(),c=n.filter(v=>v.title.toLowerCase().includes(r.toLowerCase())),h=v=>{const x={},w=new Date,$=new Date(w.getFullYear(),w.getMonth(),w.getDate()),S=new Date($);S.setDate(S.getDate()-1);const k=new Date($);return k.setDate(k.getDate()-7),v.forEach(P=>{const E=new Date(P.last_activity_at);let z;E>=$?z="Today":E>=S?z="Yesterday":E>=k?z="This Week":z="Older",x[z]||(x[z]=[]),x[z].push(P)}),x},l=async(v,x)=>{if(v.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await p(x)}catch(w){console.error("Failed to delete session:",w)}},u=v=>new Date(v).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),g=h(c);return e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsxs(Cb,{children:[e.jsxs(Sb,{children:[t&&e.jsx(zb,{onClick:()=>f(!1),children:e.jsx(Gr,{size:20})}),e.jsx($b,{children:"Conversation History"})]}),e.jsx(Eb,{children:e.jsx(Ib,{type:"text",placeholder:"Search conversations...",value:r,onChange:v=>o(v.target.value)})}),e.jsx(Pb,{children:s?e.jsx(Ub,{children:[1,2,3,4,5].map(v=>e.jsxs(Wb,{children:[e.jsx(Vb,{}),e.jsxs(Gb,{children:[e.jsx(Hb,{}),e.jsx(qb,{})]})]},v))}):c.length===0?e.jsxs(Bb,{children:[e.jsx(fa,{}),e.jsx("div",{children:"No conversations found"}),r&&e.jsx("div",{style:{fontSize:"var(--font-xs)",marginTop:"var(--space-sm)"},children:"Try a different search term"})]}):Object.entries(g).map(([v,x])=>e.jsxs(Rb,{children:[e.jsx(Tb,{children:v}),x.map(w=>e.jsxs(Mb,{onClick:()=>a(w),children:[e.jsx(Ob,{children:e.jsx(fa,{size:18})}),e.jsxs(Ab,{children:[e.jsx(Lb,{children:w.title}),e.jsxs(Db,{children:[e.jsx("span",{children:u(w.last_activity_at)}),w.status!=="idle"&&e.jsx(Nb,{$status:w.status,children:w.status.replace("_"," ")})]})]}),e.jsx(Fb,{onClick:$=>l($,w.id),children:e.jsx(nn,{size:16})})]},w.id))]},v))})]})})}const Yb=d.div`
5874
5874
  height: 100%;
5875
5875
  display: flex;
5876
5876
  flex-direction: column;
@@ -6000,12 +6000,12 @@ cursor: pointer;
6000
6000
  margin-top: var(--space-2xl);
6001
6001
  padding-top: var(--space-2xl);
6002
6002
  border-top: 1px solid var(--color-border);
6003
- `,i2=d.div`
6003
+ `,a2=d.div`
6004
6004
  display: flex;
6005
6005
  justify-content: space-between;
6006
6006
  align-items: center;
6007
6007
  margin-bottom: var(--space-md);
6008
- `,a2=d.h3`
6008
+ `,i2=d.h3`
6009
6009
  font-size: var(--font-xs);
6010
6010
  font-weight: 400;
6011
6011
  color: var(--color-muted);
@@ -6028,5 +6028,5 @@ cursor: pointer;
6028
6028
  display: flex;
6029
6029
  flex-direction: column;
6030
6030
  gap: var(--space-xs);
6031
- `;function d2(){const[t,r]=a.useState(!1),{sessions:o,selectedSession:n,showHistory:s,selectSession:i,createSession:u,setShowHistory:f}=qo(),c=async()=>{try{r(!0),await u()}finally{r(!1)}},h=l=>{try{const p=new Date(l),x=new Date().getTime()-p.getTime(),m=Math.floor(x/6e4),b=Math.floor(m/60),$=Math.floor(b/24);return $>0?`${$}d ago`:b>0?`${b}h ago`:m>0?`${m}m ago`:"Just now"}catch{return""}};return s?e.jsx(md,{showBackButton:!0}):n?e.jsx(gd,{showBackButton:!0}):e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsx(Yb,{children:e.jsxs(Zb,{children:[e.jsx(Kb,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(Qb,{children:"Hi there! 👋"}),e.jsx(Xb,{children:"How can I help you today?"}),e.jsx(Jb,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(e2,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(s2,{children:[e.jsxs(i2,{children:[e.jsx(a2,{children:"Recent Chats"}),e.jsx(c2,{onClick:()=>f(!0),children:"View All →"})]}),e.jsx(l2,{children:o.slice(0,2).map(l=>e.jsx(t2,{onClick:()=>i(l),children:e.jsxs(n2,{children:[e.jsx(r2,{children:l.title}),e.jsxs(o2,{children:[e.jsx("span",{children:h(l.last_activity_at)}),l.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},l.id))})]})]})})})}const u2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(s=>r.startsWith(s))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(s=>r.startsWith(s))},p2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=bm;exports.AgentConversation=gd;exports.AgentConversationHistory=md;exports.AgentConversationHub=d2;exports.AgentConversationProvider=Xd;exports.AuthFormImage=Pe;exports.ChannelSelector=V1;exports.CreateOrganizationForm=an;exports.CreateWorkspaceDialog=Al;exports.CreateWorkspaceForm=Ts;exports.DeploymentInitialized=zu;exports.DeploymentInitializing=$u;exports.DeploymentProvider=bd;exports.Dialog=ke;exports.DialogTrigger=Rf;exports.Dropdown=nt;exports.DropdownDivider=sn;exports.DropdownItem=Te;exports.DropdownItems=st;exports.DropdownTrigger=it;exports.Form=dt;exports.FormGroup=he;exports.Input=ce;exports.Label=ae;exports.MagicLinkVerification=pm;exports.ManageAccount=id;exports.ManageAccountDialog=ad;exports.ManageOrganization=Tl;exports.ManageWorkspace=Dl;exports.ManageWorkspaceDialog=Nl;exports.NavigateToSignIn=k1;exports.NavigateToSignUp=C1;exports.NavigationLink=ot;exports.NotificationBell=ud;exports.NotificationItem=ld;exports.NotificationPopover=dd;exports.OAuthProvider=mc;exports.ORG_ADMIN_PERMISSIONS=Bl;exports.ORG_MANAGEMENT_PERMISSIONS=Ul;exports.OTPInput=Tt;exports.OrganizationSwitcher=Hl;exports.PhoneNumberInput=qr;exports.PhoneVerification=kl;exports.ProfileCompletion=Sl;exports.RequireActiveTenancy=N1;exports.SSOCallback=om;exports.SignInForm=Lg;exports.SignUpForm=xf;exports.SignedIn=c1;exports.SignedInAccounts=_1;exports.SignedOut=l1;exports.SimpleDialog=Pf;exports.Spinner=Ee;exports.Switch=Cr;exports.TwoFactorMethodSelector=_l;exports.TwoFactorVerification=Cl;exports.UserButton=Ds;exports.UserControls=a1;exports.WORKSPACE_ADMIN_PERMISSIONS=Wl;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=Vl;exports.WaitlistForm=Xg;exports.canManageOrganization=Gl;exports.canManageWorkspace=xs;exports.clearTokenCache=_t;exports.fetchChannelCounts=wu;exports.hasIncompleteProfile=hm;exports.hasOrgPermission=Os;exports.hasWorkspacePermission=As;exports.isExternalUrl=u2;exports.isOrgAdmin=v0;exports.isSafeUrl=p2;exports.isWorkspaceAdmin=b0;exports.redirectToProfileCompletion=fm;exports.useActiveOrganization=Ze;exports.useActiveTenancy=bu;exports.useActiveWorkspace=Rt;exports.useAgentConversation=zc;exports.useAgentConversationContext=qo;exports.useChannelCounts=Su;exports.useClient=Fe;exports.useConversationSessions=fc;exports.useDeployment=ve;exports.useForgotPassword=kc;exports.useInvitation=$c;exports.useMagicLinkParams=_c;exports.useMagicLinkVerification=jc;exports.useNavigation=Ge;exports.useNotificationStream=Cc;exports.useNotifications=Sc;exports.useOrganizationList=Yo;exports.useOrganizationMemberships=Ct;exports.useSSOCallback=wc;exports.useSession=Ue;exports.useSignIn=xc;exports.useSignInWithStrategy=Br;exports.useSignUp=vc;exports.useUser=sr;exports.useUserSignins=bc;exports.useWaitlist=yc;exports.useWorkspaceList=St;exports.useWorkspaceMemberships=Zo;Object.keys(Bs).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Bs[t]})});
6031
+ `;function d2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:s,selectSession:a,createSession:p,setShowHistory:f}=qo(),c=async()=>{try{r(!0),await p()}finally{r(!1)}},h=l=>{try{const u=new Date(l),v=new Date().getTime()-u.getTime(),x=Math.floor(v/6e4),w=Math.floor(x/60),$=Math.floor(w/24);return $>0?`${$}d ago`:w>0?`${w}h ago`:x>0?`${x}m ago`:"Just now"}catch{return""}};return s?e.jsx(md,{showBackButton:!0}):n?e.jsx(gd,{showBackButton:!0}):e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsx(Yb,{children:e.jsxs(Zb,{children:[e.jsx(Kb,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(Qb,{children:"Hi there! 👋"}),e.jsx(Xb,{children:"How can I help you today?"}),e.jsx(Jb,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(e2,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(s2,{children:[e.jsxs(a2,{children:[e.jsx(i2,{children:"Recent Chats"}),e.jsx(c2,{onClick:()=>f(!0),children:"View All →"})]}),e.jsx(l2,{children:o.slice(0,2).map(l=>e.jsx(t2,{onClick:()=>a(l),children:e.jsxs(n2,{children:[e.jsx(r2,{children:l.title}),e.jsxs(o2,{children:[e.jsx("span",{children:h(l.last_activity_at)}),l.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},l.id))})]})]})})})}const u2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(s=>r.startsWith(s))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(s=>r.startsWith(s))},p2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=bm;exports.AgentConversation=gd;exports.AgentConversationHistory=md;exports.AgentConversationHub=d2;exports.AgentConversationProvider=Xd;exports.AuthFormImage=Pe;exports.ChannelSelector=V1;exports.CreateOrganizationForm=an;exports.CreateWorkspaceDialog=Al;exports.CreateWorkspaceForm=Ts;exports.DeploymentInitialized=zu;exports.DeploymentInitializing=$u;exports.DeploymentProvider=bd;exports.Dialog=ke;exports.DialogTrigger=Rf;exports.Dropdown=nt;exports.DropdownDivider=sn;exports.DropdownItem=Te;exports.DropdownItems=st;exports.DropdownTrigger=at;exports.Form=dt;exports.FormGroup=he;exports.Input=le;exports.Label=ce;exports.MagicLinkVerification=pm;exports.ManageAccount=ad;exports.ManageAccountDialog=id;exports.ManageOrganization=Tl;exports.ManageWorkspace=Dl;exports.ManageWorkspaceDialog=Nl;exports.NavigateToSignIn=k1;exports.NavigateToSignUp=C1;exports.NavigationLink=ot;exports.NotificationBell=ud;exports.NotificationItem=ld;exports.NotificationPopover=dd;exports.OAuthProvider=mc;exports.ORG_ADMIN_PERMISSIONS=Bl;exports.ORG_MANAGEMENT_PERMISSIONS=Ul;exports.OTPInput=Tt;exports.OrganizationSwitcher=Hl;exports.PhoneNumberInput=qr;exports.PhoneVerification=kl;exports.ProfileCompletion=Sl;exports.RequireActiveTenancy=N1;exports.SSOCallback=om;exports.SignInForm=Lg;exports.SignUpForm=xf;exports.SignedIn=c1;exports.SignedInAccounts=_1;exports.SignedOut=l1;exports.SimpleDialog=Pf;exports.Spinner=Ee;exports.Switch=Cr;exports.TwoFactorMethodSelector=_l;exports.TwoFactorVerification=Cl;exports.UserButton=Ds;exports.UserControls=i1;exports.WORKSPACE_ADMIN_PERMISSIONS=Wl;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=Vl;exports.WaitlistForm=Xg;exports.canManageOrganization=Gl;exports.canManageWorkspace=xs;exports.clearTokenCache=_t;exports.fetchChannelCounts=wu;exports.hasIncompleteProfile=hm;exports.hasOrgPermission=Os;exports.hasWorkspacePermission=As;exports.isExternalUrl=u2;exports.isOrgAdmin=v0;exports.isSafeUrl=p2;exports.isWorkspaceAdmin=b0;exports.redirectToProfileCompletion=fm;exports.useActiveOrganization=Ze;exports.useActiveTenancy=bu;exports.useActiveWorkspace=Rt;exports.useAgentConversation=zc;exports.useAgentConversationContext=qo;exports.useChannelCounts=Su;exports.useClient=Be;exports.useConversationSessions=fc;exports.useDeployment=ve;exports.useForgotPassword=kc;exports.useInvitation=$c;exports.useMagicLinkParams=_c;exports.useMagicLinkVerification=jc;exports.useNavigation=Ge;exports.useNotificationStream=Cc;exports.useNotifications=Sc;exports.useOrganizationList=Yo;exports.useOrganizationMemberships=Ct;exports.useSSOCallback=wc;exports.useSession=Ue;exports.useSignIn=xc;exports.useSignInWithStrategy=Br;exports.useSignUp=vc;exports.useUser=sr;exports.useUserSignins=bc;exports.useWaitlist=yc;exports.useWorkspaceList=Pt;exports.useWorkspaceMemberships=Zo;Object.keys(Bs).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Bs[t]})});
6032
6032
  //# sourceMappingURL=index.cjs.js.map