1!function(){try{var e="u">typeof window?window:"u">typeof global?global:"u">typeof globalThis?globalThis:"u">typeof self?self:{},a=(new e.Error).stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="4362a4f2-21da-4a03-b385-a90200e7e6af",e._sentryDebugIdIdentifier="sentry-dbid-4362a4f2-21da-4a03-b385-a90200e7e6af")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4522],{15283:(e,a,t)=>{t.d(a,{Fc:()=>o,TN:()=>c,XL:()=>d});var r=t(95155),s=t(12115),i=t(18460),l=t(40980);let n=(0,i.F)("relative w-full rounded-mercury border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),o=s.forwardRef(({className:e,variant:a,...t},s)=>(0,r.jsx)("div",{ref:s,role:"alert",className:(0,l.cn)(n({variant:a}),e),...t}));o.displayName="Alert";let d=s.forwardRef(({className:e,...a},t)=>(0,r.jsx)("h5",{ref:t,className:(0,l.cn)("mb-1 font-medium leading-none tracking-normal",e),...a}));d.displayName="AlertTitle";let c=s.forwardRef(({className:e,...a},t)=>(0,r.jsx)("div",{ref:t,className:(0,l.cn)("text-sm [&_p]:leading-relaxed",e),...a}));c.displayName="AlertDescription"},21767:(e,a,t)=>{t.d(a,{d:()=>n});var r=t(95155),s=t(12115),i=t(8678),l=t(40980);let n=s.forwardRef(({className:e,size:a="default",...t},s)=>(0,r.jsx)(i.bL,{ref:s,className:(0,l.cn)("allow-border-custom peer inline-flex shrink-0 cursor-pointer items-center rounded-full border shadow-control-surface transition-all duration-200 ease-out hover:data-[state=unchecked]:shadow-control-surface-hover focus-visible:outline-none focus-visible:ring-0 focus-visible:data-[state=unchecked]:shadow-control-surface-focus! disabled:cursor-not-allowed disabled:opacity-60 data-[state=unchecked]:bg-(--control-track-off-bg) data-[state=unchecked]:border-(--control-track-off) data-[state=checked]:bg-(--control-track-on-bg) data-[state=checked]:border-(--control-track-on) data-[state=checked]:shadow-control-primary hover:data-[state=checked]:shadow-control-primary-hover focus-visible:data-[state=checked]:shadow-control-primary-hover! active:data-[state=checked]:shadow-control-primary-active","lg"===a?"h-6 w-11 px-0.5":"sm"===a?"h-4 min-h-4 w-[30px] px-[3px]":"h-5 w-9 px-0.5",e),...t,children:(0,r.jsx)(i.zi,{className:(0,l.cn)("allow-border-custom pointer-events-none block rounded-full border transition-all duration-200 ease-out data-[state=unchecked]:translate-x-0 data-[state=unchecked]:bg-(--control-thumb-off) data-[state=unchecked]:border-(--control-thumb-off-border) data-[state=checked]:bg-(--control-thumb-on) data-[state=checked]:border-(--control-track-on)","lg"===a?"h-5 w-5 shadow-control-micro data-[state=checked]:translate-x-[18px]":"sm"===a?"h-3 w-3 shadow-control-micro data-[state=checked]:translate-x-[10px]":"h-4 w-4 shadow-control-micro data-[state=checked]:translate-x-[14px]")})}));n.displayName="Switch"},47687:(e,a,t)=>{t.d(a,{Xi:()=>f,av:()=>h,j7:()=>m,tU:()=>u});var r=t(95155),s=t(12115),i=t(40980),l=t(57700),n=t(30230),o=t(80642);let d=(0,s.createContext)(void 0),c=(0,s.createContext)(void 0),u=({defaultValue:e,value:a,onValueChange:t,className:l,children:n})=>{let[o,c]=(0,s.useState)(a||e||"");return(0,s.useEffect)(()=>{void 0!==a&&c(a)},[a]),(0,r.jsx)(d.Provider,{value:{selectedKey:o,setSelectedKey:e=>{c(e),t&&t(e)}},children:(0,r.jsx)("div",{className:(0,i.cn)("w-full",l),children:n})})},m=({className:e,children:a})=>{let t=e?.includes("flex-col"),n=(0,s.useId)();return(0,r.jsx)(c.Provider,{value:{indicatorLayoutId:n,isVertical:!!t},children:(0,r.jsx)(l.o,{id:n,children:(0,r.jsx)("div",{role:"tablist",className:(0,i.cn)("relative inline-flex items-center justify-center gap-1 p-1 text-muted-foreground",t?"h-auto flex-col bg-transparent":"min-h-11 rounded-full border border-border bg-muted shadow-sm",e),children:a})})})},f=({value:e,className:a,children:t,asChild:l})=>{let o=(0,s.useContext)(d),u=(0,s.useContext)(c);if(!o)throw Error("TabsTrigger must be used within a Tabs component");let{selectedKey:m,setSelectedKey:f}=o,h=m===e,p=u?.isVertical??!1;return(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":h,"data-state":h?"active":"inactive","data-selected":h,onClick:()=>{f(e)},className:(0,i.cn)("relative isolate inline-flex items-center whitespace-nowrap text-sm font-medium shadow-none transition-[color,background-color] duration-200 hover:shadow-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",p?"w-full justify-start rounded-md px-3 py-2 text-left":"h-10 justify-center rounded-full px-4 py-2",h?"text-foreground":"text-muted-foreground hover:bg-background/60 hover:text-foreground",a),children:[h&&u&&(0,r.jsx)(n.P.span,{layoutId:`${u.indicatorLayoutId}-indicator`,className:(0,i.cn)("absolute inset-0 z-0 border border-border/60 bg-background shadow-xs",p?"rounded-md":"rounded-full"),transition:{type:"spring",stiffness:380,damping:32,mass:.7}}),(0,r.jsx)("span",{className:(0,i.cn)("relative z-10 min-w-0",p?"block w-full text-left":"flex w-full items-center justify-center text-center"),children:t})]})},h=({value:e,className:a,keepMounted:t=!1,children:l})=>{let c=(0,s.useContext)(d);if(!c)throw Error("TabsContent must be used within a Tabs component");let{selectedKey:u}=c,m=u===e;return t?(0,r.jsx)(n.P.div,{role:"tabpanel",tabIndex:m?0:-1,"aria-hidden":!m,inert:!m,"data-state":m?"active":"inactive",className:(0,i.cn)("mt-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",!m&&"pointer-events-none",a),initial:!1,animate:{o
1pacity:+!!m,y:5*!m},transition:{type:"tween",duration:.18},children:l}):(0,r.jsx)(o.N,{mode:"wait",children:m&&(0,r.jsx)(n.P.div,{role:"tabpanel",tabIndex:0,"data-state":"active",className:(0,i.cn)("mt-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",a),initial:{opacity:0,y:5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},transition:{type:"tween",duration:.2},children:l},`content-${e}`)})}},64522:(e,a,t)=>{t.r(a),t.d(a,{SettingsModal:()=>eg});var r=t(95155),s=t(12115),i=t(36626),l=t(38346),n=t(84507),o=t(60529),d=t(89239),c=t(33807),u=t(18349),m=t(29991),f=t(68694),h=t(66609),p=t(83899),x=t(97916),g=t(93744),b=t(34018),v=t(2501),w=t(16294),j=t(71019),y=t(9005),N=t(86184),k=t(36893),_=t(75796),C=t(47650),S=t(15283),E=t(35484),P=t(69147);function A({isOpen:e,onOpenChange:a,currentEmail:t}){let[i,l]=(0,s.useState)(!1),[n,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)(""),[x,g]=(0,s.useState)(""),[v,w]=(0,s.useState)(""),j=(0,f.i7)();(0,s.useEffect)(()=>(l(!0),()=>l(!1)),[]);let N=()=>{n||(p(""),g(""),w(""),a(!1))},k=async()=>{if(p(""),!x||!v)return void p("All fields are required");if(x!==v)return void p("Email addresses do not match");if(x===t)return void p("New email must be different from current email");if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x))return void p("Please enter a valid email address");u(!0);try{let{error:a}=await j.auth.updateUser({email:x},{emailRedirectTo:`${(0,P.Xq)()}/api/auth/callback`});if(a){var e;let t;return void p((t=((e=a.message)||"").toLowerCase()).includes("already registered")||t.includes("already exists")||t.includes("email address not authorized")||t.includes("email already")?"That email address is already in use. Enter a different email address.":e||"An unexpected error occurred. Please try again.")}h.o.success("Email change initiated. Check both your current and new email addresses to confirm the change.",{duration:8e3}),N()}catch(e){console.error("Error updating email:",e),p("An unexpected error occurred. Please try again.")}finally{u(!1)}};return i&&e?(0,C.createPortal)((0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-100000 bg-black/50 backdrop-blur-sm",onClick:N}),(0,r.jsx)("div",{className:"fixed inset-0 z-100001 flex items-center justify-center p-4",children:(0,r.jsxs)("div",{className:"relative w-full max-w-[425px] rounded-lg border border-border bg-background shadow-dialog",onClick:e=>e.stopPropagation(),children:[(0,r.jsx)(d.$,{type:"button",variant:"ghost",size:"icon",className:"absolute right-4 top-4 shrink-0 rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background","aria-label":"Close",onClick:N,disabled:n,children:(0,r.jsx)(y.A,{className:"h-4 w-4","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"p-6",children:[(0,r.jsxs)("div",{className:"mb-4 space-y-2",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold",children:"Change Email Address"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Enter your new email address. Baxo will send confirmation links to both inboxes before the change is completed."})]}),(0,r.jsxs)("div",{className:"grid gap-4 py-4",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{className:"text-sm text-muted-foreground",children:"Current Email"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-md bg-muted p-3",children:[(0,r.jsx)(_.A,{className:"h-4 w-4 text-muted-foreground"}),(0,r.jsx)("span",{className:"text-sm font-normal",children:t})]})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"new-email",children:"New Email Address"}),(0,r.jsx)(o.p,{id:"new-email",type:"email",value:x,onChange:e=>g(e.target.value),placeholder:"Enter new email address",disabled:n})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"confirm-email",children:"Confirm New Email"}),(0,r.jsx)(o.p,{id:"confirm-email",type:"email",value:v,onChange:e=>w(e.target.value),placeholder:"Confirm new email address",disabled:n})]}),m&&(0,r.jsxs)(S.Fc,{variant:"destructive",children:[(0,r.jsx)(E.A,{className:"h-4 w-4"}),(0,r.jsx)(S.TN,{children:m})]}),(0,r.jsxs)(S.Fc,{children:[(0,r.jsx)(b.A,{className:"h-4 w-4"}),(0,r.jsx)(S.TN,{className:"text-xs",children:"Once you submit, Supabase will send confirmation emails to your current and new addresses. The change only completes after both are approved."})]})]}),(0,r.jsxs)("div",{className:"mt-6 flex justify-end gap-2",children:[(0,r.jsx)(d.$,{type:"button",variant:"outline",onClick:N,disabled:n,children:"Cancel"}),(0,r.jsx)(d.$,{type:"button",onClick:k,disabled:n,loading:n,children:"Change Email"})]})]})]})})]}),document.body):null}class F{subscribe(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(a=>a!==e)}}
1emit(){this.listeners.forEach(e=>e())}constructor(){this.listeners=[]}}let T=new F;var O=t(35625),I=t(50673),z=t(95306),$=t(7862),D=t(73321),L=t(40980),B=t(61726),J=t(74947),R=t(11968);let M="text-sm font-normal text-foreground",U="baxo_avatar_removed_at";class W extends Error{constructor(){super("Profile save timed out"),this.name="ProfileSaveTimeoutError"}}let q=async(e,a)=>{let t;try{return await Promise.race([Promise.resolve(e),new Promise((e,r)=>{t=setTimeout(()=>{a?.(),r(new W)},1e4)})])}finally{t&&clearTimeout(t)}},V=e=>{if("string"!=typeof e)return null;let a=e.trim();return a.length>0?a:null};function G({onLoadingChange:e}={}){let[a,t]=(0,s.useState)(!0),[i,l]=(0,s.useState)(!1),[n,u]=(0,s.useState)(!1),[m,p]=(0,s.useState)(null),[x,b]=(0,s.useState)(!1),v=(0,f.i7)(),w=(0,O.jE)(),j=(0,D.useRouter)(),y=(0,$.r)(),C=y?.workspaceId??null,S=y?.refreshWorkspace;(0,s.useEffect)(()=>{e?.(a)},[a,e]),(0,s.useEffect)(()=>{!async function(){t(!0);try{let{data:{user:e}}=await v.auth.getUser();if(!e)return;let{data:a,error:t}=await v.from("profiles").select("*").eq("id",e.id).maybeSingle();if(t)throw t;let r=V(e.user_metadata?.full_name)??V(e.user_metadata?.name),s=V(e.user_metadata?.job_title)??V(e.user_metadata?.jobTitle),i=(0,B.I)(e.user_metadata?.avatar_url)??(0,B.I)(e.user_metadata?.picture),l=a?.job_title??s??null,n=null;if(C){let{data:a,error:t}=await v.from("workspace_members").select("job_title").eq("workspace_id",C).eq("user_id",e.id).or(R.x_).maybeSingle();t?console.warn("Failed to load workspace-specific job title:",t):n=V(a?.job_title)}let o=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",d=null!=a,c={id:e.id,...a,full_name:a?.full_name??r??null,avatar_url:d?(0,B.I)(a?.avatar_url):i,email:a?.email??e.email??null,job_title:n??l,timezone:a?.timezone??null},u={};if(!a?.full_name&&c.full_name&&(u.full_name=c.full_name),!a?.job_title&&l&&(u.job_title=l),!d&&c.avatar_url&&(u.avatar_url=c.avatar_url),!a?.email&&c.email&&(u.email=c.email),c.timezone||(u.timezone=o,c.timezone=o),Object.keys(u).length>0)try{await v.from("profiles").upsert({id:e.id,...u,updated_at:new Date().toISOString()})}catch{}p(c)}catch(e){console.error("Error loading profile:",e),h.o.error("Failed to load profile")}finally{t(!1)}}()},[C,v]);let E=async e=>{l(!0);try{let{data:{user:a}}=await q(v.auth.getUser());if(!a)throw Error("No authenticated user");let t=e.get("job_title")?.toString()||null,r={full_name:e.get("full_name")?.toString()||null,timezone:e.get("timezone")?.toString()||m?.timezone||null,updated_at:new Date().toISOString()};C||(r.job_title=t);let{error:s}=await q(v.from("profiles").update(r).eq("id",a.id));if(s)throw s;if(C){let e=new AbortController,a=await q(fetch("/api/workspace/profile/job-title",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:C,jobTitle:t}),signal:e.signal}),()=>e.abort());if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e?.error||"Failed to update workspace job title")}}let i=m?{...m,...r,job_title:t}:null;p(i),T.emit(),a?.id&&(i&&w.setQueryData((0,z.dx)(a.id),e=>e?{...e,full_name:i.full_name,job_title:i.job_title,updated_at:i.updated_at??e.updated_at}:e),(0,I.KW)(w,a.id),w.invalidateQueries({queryKey:(0,z.dx)(a.id)})),C&&(S?.().catch(e=>{console.warn("Profile updated, but workspace context refresh failed:",e)}),j.refresh()),h.o.success("Profile updated successfully")}catch(e){console.error("Error:",e),h.o.error(e instanceof W?"Saving took too long. Please try again.":"Failed to update profile")}finally{l(!1)}},P=async e=>{let a=m?.avatar_url??null,t=!1;u(!0),p(a=>a?{...a,avatar_url:e}:null);try{let{data:{user:a}}=await v.auth.getUser();if(!a)throw Error("No authenticated user");let r=new Date().toISOString();if(!e){let{error:e}=await v.auth.updateUser({data:{[U]:r}});if(e)throw e}try{let{data:t,error:s}=await v.from("profiles").update({avatar_url:e,updated_at:r}).eq("id",a.id).select("id").single();if(s)throw s;if(t?.id!==a.id)throw Error("Profile picture update did not affect the signed-in user")}catch(s){let t=null;try{t=await v.from("profiles").select("avatar_url").eq("id",a.id).maybeSingle()}catch(e){throw new J.A("Could not verify whether the profile picture update committed",e)}if(t.error)throw new J.A("Could not verify whether the profile picture update committed",t.error);let r=t.data?.avatar_url;if(!(null!==t.data&&(null===e?null===r:(0,B.I)(r)===e)))throw s}if(t=!0,e)try{let{error:e}=await v.auth.updateUser({data:{[U]:null}});e&&console.warn("Profile picture updated, but avatar removal preference did not clear:",e)}catch(e){console.warn("Profile picture updated, but avatar removal preference did not clear:",e)}
1T.emit(),a?.id&&(w.setQueryData((0,z.dx)(a.id),a=>a?{...a,avatar_url:e,updated_at:r}:a),(0,I.KW)(w,a.id),w.invalidateQueries({queryKey:(0,z.dx)(a.id)})),h.o.success(e?"Profile picture updated":"Profile picture removed")}catch(r){if(p(r=>r?{...r,avatar_url:t?e:a}:null),console.error("Error updating avatar:",r),h.o.error("Failed to update profile picture"),t)throw new J.A("Profile picture was saved, but the client could not finish refreshing it",r);throw r}finally{u(!1)}};return a?null:m?(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault(),E(new FormData(e.currentTarget))},className:"space-y-6 max-w-2xl",children:[(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{className:M,children:"Profile Picture"}),(0,r.jsx)("div",{children:(0,r.jsx)(k.B,{value:m.avatar_url,onChange:P,disabled:i||n,deletePreviousStoredAsset:!0,showSuccessToast:!1,avatarFallbackInitials:(0,L.Vd)(m.full_name,m.email),avatarFallbackName:m.full_name,avatarFallbackEmail:m.email})})]}),(0,r.jsxs)("div",{className:"grid gap-6",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"full_name",className:M,children:"Full Name"}),(0,r.jsx)(o.p,{id:"full_name",name:"full_name",defaultValue:m.full_name||"",className:"max-w-md",disabled:i,placeholder:"Enter your full name"})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(N.n,{label:"Email",htmlFor:"email",labelClassName:M,ariaLabel:"How email works in your account",align:"start",contentClassName:"max-w-sm",info:(0,r.jsxs)(r.Fragment,{children:["This is the address you ",(0,r.jsx)("strong",{className:"font-semibold",children:"sign in"})," with and where Baxo sends"," ",(0,r.jsx)("strong",{className:"font-semibold",children:"important notifications"}),". Use ",(0,r.jsx)("strong",{className:"font-semibold",children:"Change"})," to start a secure updateâyour login switches once you confirm the new email."]})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 max-w-md",children:[(0,r.jsx)(o.p,{id:"email",type:"email",value:m.email||"",className:"flex-1",disabled:!0}),(0,r.jsxs)(d.$,{type:"button",variant:"outline",size:"default",onClick:()=>b(!0),disabled:i,className:"h-10",children:[(0,r.jsx)(_.A,{className:"h-4 w-4 mr-1"}),"Change"]})]})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"job_title",className:M,children:"Job Title"}),(0,r.jsx)(o.p,{id:"job_title",name:"job_title",defaultValue:m.job_title||"",className:"max-w-md",disabled:i,placeholder:"Enter your job title"})]})]})]}),(0,r.jsx)("div",{className:"flex justify-start pt-4",children:(0,r.jsx)(d.$,{type:"submit",disabled:i,loading:i,variant:"default",className:"w-full sm:w-auto",children:"Save Changes"})}),(0,r.jsx)(A,{isOpen:x,onOpenChange:b,currentEmail:m.email||""})]}):(0,r.jsx)("div",{className:"flex items-center justify-center h-[400px]",children:(0,r.jsxs)("div",{className:"text-center space-y-4",children:[(0,r.jsx)(g.A,{className:"w-12 h-12 text-muted-foreground mx-auto"}),(0,r.jsx)("div",{className:"text-muted-foreground",children:"Failed to load profile"}),(0,r.jsx)(d.$,{onClick:()=>window.location.reload(),size:"default",variant:"accent",children:"Try Again"})]})})}var X=t(81477),K=t(21767),Z=t(31618);let H="text-sm font-normal text-foreground",Q="text-xs text-muted-foreground",Y=({withCard:e=!1})=>{let a=(0,f.i7)(),[t,i]=(0,s.useState)(null),[l,n]=(0,s.useState)(!1),[o,u]=(0,s.useState)(!0),[m,p]=(0,s.useState)(!1),x=(0,s.useCallback)(async()=>{u(!0),p(!1),i(null);try{let{data:e,error:t}=await a.auth.getUser(),r=e.user?.id;if(t||!r)throw t||Error("No signed-in user");let{data:s,error:l}=await a.from("user_notification_preferences").select("*").eq("user_id",r).maybeSingle();if(l)throw l;s?i({...s,email_evaluations_completed:s.email_evaluations_completed??!0,email_shoutouts:s.email_shoutouts??!0}):i({user_id:r,email_evaluation_assigned:!0,email_evaluation_reminders:!0,email_evaluations_completed:!0,email_overdue_reminders:!0,email_shoutouts:!0})}catch{p(!0)}finally{u(!1)}},[a]);(0,s.useEffect)(()=>{x()},[x]);let g=e=>a=>{t&&i({...t,[e]:a})},b=async()=>
1{if(t&&!m){n(!0);try{let{error:e}=await a.from("user_notification_preferences").upsert(t,{onConflict:"user_id"});if(e)throw e;h.o.success("Notification preferences saved")}catch(e){h.o.error("Failed to save notification preferences")}finally{n(!1)}}};if(o)return null;if(m||!t){let a=(0,r.jsxs)("div",{role:"alert",className:"max-w-2xl rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Couldnât load notification preferences"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Your current choices havenât been changed. Check your connection and try again."}),(0,r.jsx)(d.$,{type:"button",variant:"outline",size:"sm",className:"mt-4",onClick:()=>void x(),disabled:o,loading:o,children:"Try again"})]});return e?(0,r.jsxs)(X.Zp,{children:[(0,r.jsxs)(X.aR,{children:[(0,r.jsx)(X.ZB,{className:"text-base font-normal text-foreground",children:"Notifications"}),(0,r.jsx)(X.BT,{className:Q,children:"Choose when Baxo emails you."})]}),(0,r.jsx)(X.Wu,{children:a})]}):a}let v=(0,Z.V0)(),w=(0,Z.V0)({context:"evaluation"}),j=(0,Z.V0)({context:"evaluation",lowercase:!0}),y=(0,r.jsxs)("div",{className:"max-w-2xl space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)(c.J,{className:H,children:["Assigned to a ",j]}),(0,r.jsxs)("p",{className:Q,children:["Get an email when youâre added to a ",j,"."]})]}),(0,r.jsx)(K.d,{checked:t.email_evaluation_assigned,onCheckedChange:g("email_evaluation_assigned")})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)(c.J,{className:H,children:[w," reminders"]}),(0,r.jsx)("p",{className:Q,children:"Receive reminders as deadlines approach."})]}),(0,r.jsx)(K.d,{checked:t.email_evaluation_reminders,onCheckedChange:g("email_evaluation_reminders")})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)(c.J,{className:H,children:[v," completed"]}),(0,r.jsxs)("p",{className:Q,children:["Get an email when a ",v.toLowerCase()," youâre part of is completed. If you created it, youâll get the detailed version."]})]}),(0,r.jsx)(K.d,{checked:t.email_evaluations_completed,onCheckedChange:g("email_evaluations_completed")})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)(c.J,{className:H,children:"Overdue reminders"}),(0,r.jsx)("p",{className:Q,children:"Get notified if anything slips past due."})]}),(0,r.jsx)(K.d,{checked:t.email_overdue_reminders,onCheckedChange:g("email_overdue_reminders")})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)(c.J,{className:H,children:"Shoutouts & mentions"}),(0,r.jsx)("p",{className:Q,children:"Get an email when someone gives you a shoutout or mentions you."})]}),(0,r.jsx)(K.d,{checked:t.email_shoutouts,onCheckedChange:g("email_shoutouts")})]}),(0,r.jsx)("div",{className:"flex justify-start pt-2",children:(0,r.jsx)(d.$,{onClick:b,disabled:l||m,loading:l,className:"w-full sm:w-auto",children:"Save Changes"})})]});return e?(0,r.jsxs)(X.Zp,{children:[(0,r.jsxs)(X.aR,{children:[(0,r.jsx)(X.ZB,{className:"text-base font-normal text-foreground",children:"Notifications"}),(0,r.jsx)(X.BT,{className:Q,children:"Choose when Baxo emails you."})]}),(0,r.jsx)(X.Wu,{children:y})]}):y};var ee=t(41882),ea=t(33347),et=t(53368),er=t(18310),es=t(30230),ei=t(93561),el=t(45160),en=t(47687),eo=t(13276),ed=t(42763),ec=t(38064),eu=t(13183),em=t(66055),ef=t(87874);let eh="font-sans text-base font-semibold text-foreground",ep="text-sm font-normal text-foreground",ex=[{id:"google",label:"Google",description:"Sign in with Google",icon:function({className:e}){return(0,r.jsx)("svg",{viewBox:"0 0 24 24",className:e,"aria-hidden":!0,children:(0,r.jsx)("path",{fill:"currentColor",d:"M21.35 11.1H12v2.95h5.32c-.23 1.5-1.61 4.39-5.32 4.39-3.2 0-5.82-2.65-5.82-5.94S8.8 6.56 12 6.56c1.82 0 3.04.78 3.74 1.45l2.55-2.46C16.65 4.02 14.54 3.1 12 3.1 6.74 3.1 2.48 7.36 2.48 12.5S6.74 21.9 12 21.9c6.92 0 9.16-4.86 9.16-7.38 0-.5-.05-.88-.15-1.26z"})})}}];function eg({isOpen:e,onClose:a,defaultSection:t="profile"}){let{workspace:N,refreshWorkspace:_}=(0,i.h)(),C=(0,et.a)(),S=(0,D.useRouter)(),E=(0,D.usePathname)(),A=(0,D.useSearchParams)(),[F,T]=(0,s.use
1State)(t),[I,z]=(0,s.useState)(!1),[$,B]=(0,s.useState)(N?.company_size||""),[J,M]=(0,s.useState)(N?.timezone||"UTC"),[U,W]=(0,s.useState)(!1),[q,V]=(0,s.useState)(!1),[X,K]=(0,s.useState)(""),[Z,H]=(0,s.useState)(!1),[Q,eb]=(0,s.useState)(!1),[ev,ew]=(0,s.useState)(!1),[ej,ey]=(0,s.useState)(null),[eN,ek]=(0,s.useState)(null),[e_,eC]=(0,s.useState)(!1),[eS,eE]=(0,s.useState)(!1),[eP,eA]=(0,s.useState)(null),[eF,eT]=(0,s.useState)(!1),[eO,eI]=(0,s.useState)(null),[ez,e$]=(0,s.useState)([]),[eD,eL]=(0,s.useState)(null),[eB,eJ]=(0,s.useState)(void 0),[eR,eM]=(0,s.useState)(""),[eU,eW]=(0,s.useState)(null),[eq,eV]=(0,s.useState)(!1),eG=(0,s.useRef)(null),eX=(0,s.useRef)(0),eK=(0,s.useRef)({workspaceId:N?.id??null,isOpen:e});eK.current={workspaceId:N?.id??null,isOpen:e};let eZ=(0,f.i7)(),eH=(0,O.jE)(),{role:eQ,permissions:eY,loading:e0}=(0,l.h)(),e1=(0,er.I)(),e2=(0,s.useCallback)(e=>{eT(!e)},[]),e4=(0,s.useCallback)(()=>{if(!N?.id)return null;let e=eX.current+1;return eX.current=e,{workspaceId:N.id,generation:e}},[N?.id]),e5=(0,s.useCallback)(e=>{let a=eK.current;return a.isOpen&&a.workspaceId===e.workspaceId&&eX.current===e.generation},[]),e3=(0,s.useCallback)(async e=>{if(!N?.id)return"available";try{let a=await fetch("/api/workspaces/check-handle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handle:e,exceptWorkspaceId:N.id})});if(!a.ok)return"unavailable";let t=await a.json();if(!0===t.exists)return"taken";if(!1===t.exists)return"available";return"unavailable"}catch{return"unavailable"}},[N?.id]),e6=async()=>{let e=eO?.id;if(e)return void(0,ei.l8)(eH,e);let{data:a}=await eZ.auth.getUser(),t=a.user?.id;t&&(0,ei.l8)(eH,t)},e8=(0,s.useMemo)(()=>{let e=[{id:"profile",title:"Account",description:"Personal settings",icon:g.A},{id:"notifications",title:"Notifications",description:"Email preferences",icon:b.A},{id:"workspace",title:"Workspace",description:"Company settings",icon:v.A,requiredPermission:"canManageWorkspace"},{id:"billing",title:"Billing",description:"Subscription",icon:w.A,requiredPermission:"canManageBilling"}];return"member"===eQ?e.filter(e=>["profile","notifications"].includes(e.id)):e},[eQ]);(0,s.useEffect)(()=>{e&&!Z&&(T(t),H(!0)),e||(H(!1),eJ(void 0),eT(!1),V(!1),K(""))},[e,t,Z]),(0,s.useEffect)(()=>{e&&(eM(N?.handle??""),eW(null),eG.current=null)},[e,N?.id,N?.handle]),(0,s.useEffect)(()=>{if(!e||"workspace"!==F||!N?.id)return;let a=eR.trim(),t=a.toLowerCase();if(!a||!/^[a-z0-9-]+$/.test(t))return void eW("invalid");if(t===(N.handle||"").trim().toLowerCase())return void eW(null);if("soon-studio"===t||"soonstudio"===t)return void eW("taken");eG.current=t;let r=window.setTimeout(()=>{(async()=>{eV(!0);try{let e=await e3(t);if(eG.current!==t)return;eW("available"===e?null:e)}finally{eV(!1)}})()},500);return()=>clearTimeout(r)},[eR,e,F,N?.id,N?.handle,e3]),(0,s.useEffect)(()=>{B(N?.company_size||""),M(N?.timezone||"UTC")},[N]),(0,s.useEffect)(()=>{e&&eT(!1)},[e,N?.id]),(0,s.useEffect)(()=>{e&&(async()=>{let{data:e,error:a}=await eZ.auth.getUser();if(a)return console.error("Failed to load user for connected accounts",a);let t=e?.user??null;eI(t),e$(t?.identities?.map(e=>e.provider)??[])})()},[e,eZ]),(0,s.useEffect)(()=>{e||(eX.current+=1,ek(null),eC(!1),eE(!1),eA(null),ey(null))},[e]),(0,s.useEffect)(()=>{eX.current+=1,ek(null),eC(!1),eE(!1),eA(null),ey(null)},[N?.id]),(0,s.useEffect)(()=>{"integrations"===F&&T("profile")},[F]);let e9=e=>{T(e)},e7=async e=>{z(!0);try{let t=N?.handle??"",r=e.get("name"),s=eR.trim();if(!s){eW("invalid"),z(!1);return}let i=s.toLowerCase();if(!/^[a-z0-9-]+$/.test(i)){eW("invalid"),z(!1);return}if("taken"===eU||"invalid"===eU)return void z(!1);if(i!==t.trim().toLowerCase()){if("soon-studio"===i||"soonstudio"===i){eW("taken"),z(!1);return}let e=await e3(i);if("available"!==e){eW(e),z(!1);return}}
1let l=e.get("timezone"),n=e.get("company_website"),o=e.get("company_description"),{error:d}=await eZ.from("workspaces").update({name:r,handle:i,timezone:l||"UTC",company_website:n||null,company_description:o||null,company_size:$||null,...void 0!==eB?{logo_url:eB}:{}}).eq("id",N?.id);if(d)throw d;await new Promise(e=>setTimeout(e,500)),await _?.(),eJ(void 0),eM(i),await e6();let c=t.trim().toLowerCase();if(i&&i!==c){let e,t=A?.toString()??"",r=t?`?${t}`:"",s=(E??"").split("/").filter(Boolean);s.length>0&&s[0].toLowerCase()===c?(s[0]=i,e=`/${s.join("/")}${r}`):e=`/${i}/home${r}`,S.replace(e),a()}S.refresh(),h.o.success("Workspace settings updated successfully")}catch(e){(0,p.G9)("Failed to update workspace settings",e,{action:"update_workspace_settings",workspaceId:N?.id})}finally{z(!1)}},ae=e=>{eJ(e)},aa=void 0!==eB?eB:N?.logo_url??null,at=async()=>{if("owner"===eQ&&N?.id&&X.trim()===N.handle&&!U){W(!0);try{let e=await fetch(`/api/workspaces/${N.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirmation:X.trim()})});if(!e.ok){let a=await e.json().catch(()=>({}));throw Error(a?.error||"Failed to delete workspace")}h.o.success("Workspace deleted"),V(!1),K(""),a(),await e6();let{data:{user:t}}=await eZ.auth.getUser(),r=t?.id;if(r){let{data:e}=await eZ.from("workspace_members").select("workspace:workspaces(handle)").eq("user_id",r).or(R.x_).limit(1),a=e?.[0]?.workspace,t=Array.isArray(a)?a[0]?.handle:a?.handle;if(t&&"string"==typeof t){S.replace(`/${t}/home`),S.refresh();return}}await eZ.auth.signOut(),window.location.assign("/login")}catch(e){(0,p.G9)("Failed to delete workspace",e,{action:"delete_workspace",workspaceId:N?.id})}finally{W(!1)}}},ar=async()=>{if(!N?.id)return void h.o.error("Workspace not found. Please refresh and try again.");eb(!0);try{let e=await fetch("/api/billing/customer-portal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:N.id})});if(!e.ok){let a=await e.json().catch(()=>({})),t=a?.error||"Failed to open billing portal";throw Error(t)}let a=await e.json();if(a?.url)return void window.location.assign(a.url);throw Error("Missing portal URL")}catch(e){(0,p.G9)(e instanceof Error?e.message:"Failed to open billing portal",e,{action:"open_billing_portal",workspaceId:N?.id})}finally{eb(!1)}},as=()=>{N?.handle?(a(),S.push(`/${N.handle}/billing/required-checkout`)):h.o.error("Workspace not found. Please refresh and try again.")},ai=e=>{if(!e)return"â";let a=new Date(e);return Number.isNaN(a.getTime())?"â":a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},al=(0,ef.F9)(N),an=al?ef.WM:eN?.status||N?.subscription_status||"none",ao=eN?.currentPeriodEnd??N?.subscription_current_period_end??null,ad=eS?eN?.cancelAt??null:eN?.cancelAt??N?.cancel_at??null,ac=!!eN?.cancelAtPeriodEnd,au=eN?.discount??null,am=!!au?.isFreeForever,af=au?.name?.trim()||null,ah=au?.promotionCode?.trim()||null,ap=!!(au?.percentOff===100&&[af,ah].some(e=>{let a=e?.toLowerCase()??"";return a.includes("design")&&a.includes("partner")})),ax=ap?af??"Free Design Partner":"Baxo Pro",ag=(0,ec.w5)(eN?.billingModel??N?.billing_model)===ec.KS,ab=ad?Date.parse(ad):NaN,av=Number.isFinite(ab)&&ab>Date.now(),aw=("trialing"===an||"active"===an)&&(ac||av),aj="canceled"===an||"cancelled"===an,ay=eN?.trialEndsAt??N?.trial_ends_at??null,aN="trialing"===an,ak=!al&&ag&&!N?.stripe_subscription_id,a_=(()=>{var e,a;if(!au)return null;if(ap)return ax;if(null!=au.percentOff)return`${au.percentOff}% off`;let t=(e=au.amountOff,a=au.currency,null!=e&&a?new Intl.NumberFormat("en-US",{style:"currency",currency:a.toUpperCase()}).format(e/100):null);return t?`${t} off`:au.promotionCode||au.name||"Applied"})(),aC=au?au.isFreeForever?"Free forever":au.endsAt?`Ends ${ai(au.endsAt)}`:"forever"===au.duration?"Does not expire":au.promotionCode||au.name||"Coupon applied":null,aS=(0,s.useCallback)(async e=>{let{count:a,error:t}=await eZ.from("workspace_members").select("id",{count:"exact",head:!0}).eq("workspace_id",e.workspaceId).or("status.is.null,status.eq.active").not("role","eq","pending");if(t)return e5(e)&&console.error("Failed to load seat count:",t),null;let r=a??null;return e5(e)&&ey(r),r},[e5,eZ]),aE=!N?.stripe_subscription_id||am||aw||aj?null:ao,aP=am?null:ap&&au?.endsAt?{label:"Design Partner ends",value:ai(au.endsAt),helper:"Billing starts automatically after this date."}:aw||aj?{label:"Access ends",value:ai(ad||ao),helper:null}:aN?{label:"Trial ends",value:ai(ay),helper:"Billing starts automatically after trial."}:N?.stripe_subscription_id&&"active"===an?{label:"Next renewal",value:aE?ai(aE):"Date in Stripe",helper:null}:null,aA=(0,s.useCallback)(async(e,a)=>{try{let t=await fetch("/api/billing/subscription-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:e.workspaceId}),signal:a});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||"Could not load billing details")}let r=await t.json();if(!e5(e))return!1;return ek({status:"string"==typeof r?.status?r.status:null,currentPeriodEnd:"string"==typeof r?.currentPeriodEnd?r.currentPeriodEnd:null,billingModel:"string"==typeof r?.billingModel?r.billingModel:null,trialEndsAt:"string"==typeof r?.trialEndsAt?r.trialEndsAt:null,cancelAt:"string"==typeof r?.cancelAt?r.cancelAt:null,cancelAtPeriodEnd:!!r?.cancelAtPeriodEnd,licensedSeatQuantity:"number"==typeof r?.licensedSeatQuantity?r.licensedSeatQuantity:null,discount:r?.discount&&"object"==typeof r.discount?{name:"string"==typeof r.discount.name?r.discount.name:null,promotionCode:"string"==typeof r.discount.promotionCode?r.discount.promotionCode:null,percentOff:"number"==typeof r.discount.percentOff?r.discount.percentOff:null,amountOff:"number"==typeof r.discount.amountOff?r.discount.amountOff:null,currency:"str
1ing"==typeof r.discount.currency?r.discount.currency:null,duration:"string"==typeof r.discount.duration?r.discount.duration:null,endsAt:"string"==typeof r.discount.endsAt?r.discount.endsAt:null,isFreeForever:!!r.discount.isFreeForever}:null}),eA(null),!0}catch(a){if(a?.name==="AbortError"||!e5(e))return!1;return console.error("Failed to load subscription info:",a),eA("Billing details could not be loaded. Your subscription was not changed."),!1}},[e5]),aF=(0,s.useCallback)(async({signal:e}={})=>{let a=e4();if(!a)return!1;e5(a)&&(eC(!0),eA(null));try{let[t]=await Promise.all([aA(a,e),aS(a)]);if(!e5(a))return!1;return t&&eE(!0),t}finally{e5(a)&&eC(!1)}},[e4,e5,aS,aA]);(0,s.useEffect)(()=>{if(!e||!N?.id||!eY.canManageBilling)return;let a=new AbortController;return aF({signal:a.signal}),()=>{a.abort(),eX.current+=1}},[e,N?.id,eY.canManageBilling,aF]),(0,s.useEffect)(()=>{if(!e||"billing"!==F)return;let a=()=>{aF(),_?.()};return window.addEventListener("focus",a),()=>{window.removeEventListener("focus",a)}},[e,F,aF,_]);let aT=(0,s.useCallback)(async()=>{await aF()},[aF]),aO=(0,s.useCallback)(async()=>{if(N?.id){ew(!0);try{let e=await fetch("/api/billing/resume-subscription",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:N.id})});if(!e.ok){let a=await e.json().catch(()=>({})),t="string"==typeof a.error?a.error:"Could not keep your membership";throw Error(t)}h.o.success("Renewal is back on. Your membership continues."),await aF(),await _?.()}catch(e){(0,p.G9)(e instanceof Error?e.message:"Could not keep your membership",e,{action:"resume_subscription",workspaceId:N?.id})}finally{ew(!1)}}},[N?.id,aF,_]),aI=()=>{K(""),V(!0)},az=async e=>{if(!eD){eL(e);try{let{error:a}=await eZ.auth.linkIdentity({provider:e,options:{redirectTo:`${(0,P.Xq)()}/api/auth/callback`}});if(a)throw a;h.o.message("Complete the connection in the popup to finish linking.")}catch(a){(0,p.G9)("Failed to connect account. Please try again.",a,{action:"link_identity",metadata:{provider:e}}),eL(null)}}},a$=()=>{let e=ex.filter(e=>ez.includes(e.id)),a=1===e.length?e:ex;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("h3",{className:ep,children:"Connected accounts"}),eO?(0,r.jsx)("div",{className:"space-y-3",children:a.map(e=>{let a=ez.includes(e.id),t=eD===e.id,s=e.icon;return(0,r.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,r.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center text-foreground","aria-hidden":!0,children:(0,r.jsx)(s,{className:"h-4 w-4","aria-hidden":!0})}),(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description}),a&&(0,r.jsx)(el.E,{variant:"secondary",children:"Connected"})]})]}),(0,r.jsx)(d.$,{type:"button",variant:"outline",size:"sm",disabled:a||t,loading:t,onClick:()=>az(e.id),children:a?"Connected":"Connect"})]},e.id)})}):(0,r.jsx)("div",{className:"rounded-lg border border-border bg-card p-4 text-sm text-muted-foreground",children:"Sign in to manage connected accounts."})]})},aD="owner"===eQ&&!e0&&N?(0,r.jsx)(eo.Lt,{open:q,onOpenChange:e=>{V(e),e||K("")},children:(0,r.jsxs)(eo.EO,{className:"sm:max-w-[480px]","data-testid":"settings-workspace-delete-confirm-dialog",children:[(0,r.jsxs)(eo.wd,{className:"space-y-3",children:[(0,r.jsxs)(eo.r7,{className:"text-foreground",children:["Delete ",N.name," permanently?"]}),(0,r.jsx)(eo.$v,{className:"text-muted-foreground",children:"This removes the workspace and all associated projects, evaluations, member roles, and invitations. This action cannot be undone."})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsxs)(c.J,{htmlFor:"delete-workspace-confirm",className:ep,children:["Type ",(0,r.jsx)("span",{className:"font-medium text-foreground",children:N.handle})," to confirm"]}),(0,r.jsx)(o.p,{id:"delete-workspace-confirm",value:X,onChange:e=>K(e.target.value),placeholder:N.handle,className:"bg-input",autoComplete:"off",autoFocus:!0})]}),(0,r.jsxs)(eo.ck,{className:"flex flex-col gap-2 sm:flex-row sm:justify-end sm:space-x-0",children:[(0,r.jsx)(eo.Zr,{type:"button",disabled:U,children:"Cancel"}),(0,r.jsx)(d.$,{type:"button",variant:"destructive",loading:U,disabled:X.trim()!==N.handle||U,onClick:()=>void at(),children:"Permanently delete"})]})]})}):null;return(0,r.jsxs)(ed.lG,{open:e,onOpenChange:e=>{e||a()},children:[(0,r.jsxs)(ed.Cf,{hideCloseButton:!0,className:(0,L.cn)("flex min-h-0 gap-0 overflow-hidden p-0","member"===eQ?"h-[min(720px,calc(100dvh-2rem))] max-w-2xl":"h-[min(820px,calc(100dvh-2rem))] max-w-4xl"),children:[(0,r.jsx)(ed.L3,{className:"sr-only",children:"Settings"}),(0,r.jsx)(ed.rr,{className:"sr-only",children:"Manage your account, workspace, notifications, and billing settings."}),(0,r.jsx)("div",{className:"absolute top-4 right-4 z-10",children:(0,r.jsx)(ed.HM,{asChild:!0,children:(0,r.jsx)(d.$,{type:"button",variant:"ghost",size:"icon","aria-label":"Close settings",className:"shrink-0 rounded-lg text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",children:(0,r.jsx)(y.A,{className:"h-4 w-4","aria-hidden":!0})})})}),"member"===eQ?(0,r.jsxs)(en.tU,{value:"notifications"===F?"notifications":"profile",onValueChange:e9,className:"flex h-full min-h-0 flex-col",children:[(0,r.jsxs)("div",{className:"p-4 sm:p-6 border-b",children:[(0,r.jsx)("h2",{className:"text-xl font-heading text-foreground",children:"Account Settings"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage your personal account settings and preferences"}),(0,r.jsxs)(en.j7,{className:"mt-5 w-full max-w-sm",children:[(0,r.jsx)(en.Xi,{value:"profile",className:"flex-1",children:"Account"}),(0,r.jsx)(en.Xi,{value:"notifications",className:"flex-1",children:"Notifications"})]})]}),(0,r.jsxs)("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[(0,r.jsx)(en.av,{value:"profile",keepMounted:!0,className:"absolute inset-0 mt-0 overflow-y-auto p-4 sm:p-6",children:(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(G,{onLoadingChange:e2}),!C&&eF?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.w,{}),a$(),(0,r.jsx)(x.w,{}),(0,r.jsx)(ea.C,{})]}):null]})}),(0,r.jsx)(en.av,{value:"notifications",keepMounted:!0,className:"absolute inset-0 mt-0 overflow-y-auto p-4 sm:p-6",children:(0,r.jsx)("div",{className:"max-w-2xl",children:(0,r.jsx)(Y,{withCard:!1})})})]})]}):(0,r.jsxs)("div",{className:"flex flex-1 min-h-0 flex-col sm:flex-row",children:[(0,r.jsxs)("div",{className:"w-full sm:w-64 border-b sm:border-b-0 sm:border-r bg-muted shrink-0",children:[(0,r.jsx)("div",{className:"p-4 border-b",children:(0,r.jsx)("h3",{className:"font-heading text-lg text-foreground",children:"Settings"})}),(0,r.jsx)("nav",{className:"p-3",children:(0,r.jsx)("div",{className:"grid grid-cols-5 ga
1p-2 sm:block sm:space-y-1",children:e8.map(e=>{let a=e.icon,t=F===e.id,s=e.requiredPermission?eY[e.requiredPermission]:!e.requiredRole||e.requiredRole.includes(eQ),i=!e0&&!s;return(0,r.jsxs)("button",{type:"button",disabled:i,onClick:()=>{i||e9(e.id)},className:(0,L.cn)("w-full flex items-center justify-center sm:justify-start gap-3 px-3 py-2.5 text-left rounded-lg transition-colors cursor-pointer appearance-none bg-transparent",t?"bg-accent text-foreground ring-1 ring-border":"text-muted-foreground hover:text-foreground hover:bg-accent",i&&"opacity-50 cursor-not-allowed hover:bg-transparent"),"aria-label":e.title,children:[(0,r.jsx)(a,{className:(0,L.cn)("w-5 h-5 sm:w-4 sm:h-4",t?"text-foreground":"text-muted-foreground")}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 hidden sm:block",children:[(0,r.jsx)("div",{className:(0,L.cn)("text-sm font-normal","text-foreground"),children:e.title}),e.description&&(0,r.jsx)("div",{className:(0,L.cn)("text-xs","text-muted-foreground"),children:e.description})]})]},e.id)})})})]}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col min-h-0",children:[(0,r.jsxs)("div",{className:"shrink-0 p-4 sm:p-6 border-b",children:["profile"===F&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-xl font-heading text-foreground",children:"Account"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage your personal account settings and preferences"})]}),"workspace"===F&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-xl font-heading text-foreground",children:"Workspace"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Configure your workspace name, branding, and company information"})]}),"team"===F&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-xl font-heading text-foreground",children:"Team"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage team members, roles, and permissions"})]}),"billing"===F&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-xl font-heading text-foreground",children:"Billing"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage your subscription and billing information"})]}),"notifications"===F&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-xl font-heading text-foreground",children:"Notifications"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Choose when Baxo emails you"})]})]}),(0,r.jsx)("div",{className:"relative min-h-0 flex-1 overflow-hidden",children:e8.map(e=>{let a=F===e.id;return(0,r.jsx)(es.P.div,{"aria-hidden":!a,className:(0,L.cn)("absolute inset-0 overflow-y-auto overscroll-contain p-4 sm:p-6",!a&&"pointer-events-none"),initial:!1,animate:e1?{opacity:+!!a}:{opacity:+!!a,y:6*!a},transition:{duration:.16,ease:"easeOut"},style:{visibility:a?"visible":"hidden"},children:(0,r.jsx)("div",{className:"min-h-full",children:((e=F)=>{switch(e){case"profile":return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(G,{onLoadingChange:e2}),!C&&eF?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.w,{}),a$(),(0,r.jsx)(x.w,{}),(0,r.jsx)(ea.C,{})]}):null]});case"notifications":return(0,r.jsx)(Y,{});case"workspace":return(0,r.jsx)(n.JP,{permission:"canManageWorkspace",children:(0,r.jsx)("form",{onSubmit:e=>{e.preventDefault(),e7(new FormData(e.currentTarget))},children:(0,r.jsxs)("div",{className:"space-y-8",children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"name",className:ep,children:"Workspace Name"}),(0,r.jsx)(o.p,{id:"name",name:"name",defaultValue:N?.name||"",placeholder:"Enter workspace name"})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"handle",className:ep,children:"Workspace Handle"}),(0,r.jsx)(o.p,{id:"handle",placeholder:"workspace-handle",value:eR,onChange:e=>eM(e.target.value),disabled:I,className:"bg-input",autoComplete:"off"}),"taken"===eU?(0,r.jsx)("p",{className:"text-sm font-medium text-destructive",children:"This workspace URL is already taken."}
1):null,"invalid"===eU?(0,r.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Use lowercase letters, numbers, and hyphens only."}):null,"unavailable"===eU?(0,r.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Could not check availability. Please try again."}):null,eq&&!eU?(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Checking availabilityâ¦"}):null]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{className:ep,children:"Workspace Timezone"}),(0,r.jsx)(ee.J,{value:J,onValueChange:M,disabled:I})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"logo",className:ep,children:"Workspace Logo"}),(0,r.jsx)("div",{children:(0,r.jsx)(k.B,{onChange:ae,value:aa,bucket:"workspace-avatar",preserveStoredAssetOnRemove:!0})})]})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"company_website",className:ep,children:"Company Website"}),(0,r.jsx)(o.p,{id:"company_website",name:"company_website",type:"url",placeholder:"https://company.com",defaultValue:N?.company_website||""})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"company_description",className:ep,children:"What does your company do?"}),(0,r.jsx)(u.T,{id:"company_description",name:"company_description",placeholder:"We are a technology company that builds software solutions for...",defaultValue:N?.company_description||"",className:"min-h-[80px]"})]}),(0,r.jsxs)("div",{className:"grid gap-2",children:[(0,r.jsx)(c.J,{htmlFor:"company_size",className:ep,children:"Company Size"}),(0,r.jsxs)(m.l6,{value:$,onValueChange:B,children:[(0,r.jsx)(m.bq,{children:(0,r.jsx)(m.yv,{placeholder:"Select company size"})}),(0,r.jsxs)(m.gC,{className:"z-100000",children:[(0,r.jsx)(m.eb,{value:"1-10",children:"1-10 employees"}),(0,r.jsx)(m.eb,{value:"11-50",children:"11-50 employees"}),(0,r.jsx)(m.eb,{value:"51-200",children:"51-200 employees"}),(0,r.jsx)(m.eb,{value:"201-1000",children:"201-1000 employees"}),(0,r.jsx)(m.eb,{value:"1000+",children:"1000+ employees"})]})]})]})]}),(0,r.jsxs)("div",{className:(0,L.cn)("flex flex-col gap-3 pt-2 sm:flex-row sm:items-center","owner"!==eQ||e0?"sm:justify-end":"sm:justify-between"),children:["owner"!==eQ||e0?null:(0,r.jsx)(d.$,{type:"button",variant:"destructive",size:"default",disabled:U,onClick:aI,className:"order-2 w-full shadow-control-surface hover:shadow-control-surface-hover focus-visible:shadow-control-surface-focus! active:shadow-control-surface sm:order-2 sm:ml-auto sm:w-auto",children:"Delete workspace"}),(0,r.jsx)(d.$,{variant:"primary",type:"submit",disabled:I||eq||"taken"===eU||"invalid"===eU||!eR.trim()||!/^[a-z0-9-]+$/.test(eR.trim().toLowerCase()),loading:I,className:"order-1 w-full bg-foreground text-background hover:bg-foreground
1/90 sm:order-1 sm:w-auto",children:"Save Changes"})]})]})},N?.id??"workspace")});case"billing":{let e=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(eu.S),a=al||am?{label:"Free forever",variant:"mercury-success"}:ap?{label:"Free Design Partner",variant:"mercury-success"}:N?.stripe_subscription_id?aw?{label:"Ending",variant:"mercury-error"}:"trialing"===an?{label:"Free Trial",variant:"mercury-success"}:"active"===an?{label:"Active",variant:"mercury-success"}:"past_due"===an?{label:"Past due",variant:"destructive"}:"canceled"===an||"cancelled"===an?{label:"Canceled",variant:"secondary"}:{label:an.replace("_"," "),variant:"secondary"}:{label:"No subscription",variant:"secondary"};return(0,r.jsx)(n.JP,{permission:"canManageBilling",children:(0,r.jsxs)("div",{className:"space-y-6",children:[al||!e_||eS?null:(0,r.jsx)("div",{role:"status",className:"rounded-xl border border-border bg-muted/50 p-4 text-sm text-muted-foreground shadow-card",children:"Loading billing detailsâ¦"}),!al&&eP?(0,r.jsxs)("div",{role:"alert",className:"flex flex-col gap-3 rounded-xl border border-destructive/30 bg-destructive/5 p-4 shadow-card sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Billing details are unavailable"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:eP})]}),(0,r.jsx)(d.$,{type:"button",variant:"outline",size:"sm",className:"w-full shrink-0 sm:w-auto",loading:e_,disabled:e_,onClick:()=>void aT(),children:"Try again"})]}):null,aw&&!aj&&N?.stripe_subscription_id?(0,r.jsx)("div",{className:"rounded-xl border border-border bg-muted/50 p-4 shadow-card sm:p-5",children:(0,r.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,r.jsx)("p",{className:eh,children:"Cancellation scheduled"}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Access stays through ",ai(ad||ao),". You can keep Baxo Pro."]})]}),(0,r.jsx)(d.$,{type:"button",variant:"default",size:"sm",className:"w-full shrink-0 sm:w-auto",loading:ev,disabled:ev,onClick:aO,children:"Don't cancel membership"})]})}):null,(0,r.jsx)("div",{className:"rounded-xl border border-border bg-card p-4 shadow-card sm:p-5",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[(0,r.jsxs)("div",{className:"min-w-0 space-y-2 sm:max-w-md",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("p",{className:eh,children:ax}),(0,r.jsx)(el.E,{variant:a.variant,className:"mercury-success"===a.variant?"hover:border-importance-low/35! hover:bg-importance-low/12!":"mercury-error"===a.variant?"hover:border-destructive/35! hover:bg-destructive/14!":void 0,children:a.label})]}),(0,r.jsx)("p",{className:"max-w-sm text-sm leading-snug text-muted-foreground [text-wrap:balance]",children:ap?"Your Design Partner plan is active. Billing starts automatically when the promotion ends.":am?"Your free forever discount is active. Invoices and payment methods live in Stripe.":al?"This workspace is free and has no Stripe billing.":aN?"Your trial is active. Billing starts automatically when the trial ends.":ak?"Add a payment method to start your 30-day trial.":"Invoices and payment methods live in Stripe."})]}),al?null:(0,r.jsx)("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:shrink-0 sm:flex-row sm:justify-end",children:(0,r.jsxs)(d.$,{variant:"default",size:"sm",onClick:ak?as:ar,loading:!ak&&Q,disabled:!ak&&Q,className:"w-full sm:w-auto",children:[Q?null:(0,r.jsx)(j.A,{className:"h-3 w-3","aria-hidden":!0}),ak?"Complete billing":"Manage in Stripe"]})})]})}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[(0,r.jsxs)("div",{className:"flex flex-col rounded-lg border border-border bg-card p-4 shadow-card",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Member count"}),(0,r.jsx)("p",{className:"mt-2 text-sm font-semibold tabular-nums leading-snug text-foreground",children:ej??"â"}),null!=ej?(0,r.jsx)("p",{className:"mt-2 text-xs leading-snug text-muted-foreground [text-wrap:balance]",children:ap?"Covered by Design Partner Plan":am?"Covered by free forever coupon":ag?"Billed as active users after trial":`${ec.Cm} free members`}):null]}),(0,r.jsxs)("div",{className:"flex flex-col rounded-lg border border-border bg-card p-4 shadow-card",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Pricing"}),(0,r.jsxs)("p",{className:"mt-2 text-sm font-semibold tabular-nums leading-snug text-foreground",children:[e,(0,r.jsx)("span",{className:"text-muted-foreground",children:" / user / month"})]}),(0,r.jsx)("p",{className:"mt-2 text-xs leading-snug text-muted-foreground [text-wrap:balance]",children:ap?"Covered by Design Partner Plan":am?"Covered by free forever coupon":ag?"After free trial":`First ${ec.Cm} members included`})]}),aP?(0,r.jsxs)("div",{className:"flex flex-col rounded-lg border border-border bg-card p-4 shadow-card",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:aP.label}),(0,r.jsx)("p",{className:"mt-2 text-sm font-semibold leading-snug text-foreground",children:aP.value}),aP.helper?(0,r.jsx)("p",{className:"mt-2 text-xs leading-snug text-muted-foreground [text-wrap:balance]",children:aP.helper}):null]}):null,au?(0,r.jsxs)("div",{className:"flex flex-col rounded-lg border border-border bg-card p-4 shadow-card",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Discount"}),(0,r.jsx)("p",{className:"mt-2 text-sm font-semibold leading-snug text-foreground",children:a_}),aC?(0,r.jsx)("p",{className:"mt-2 text-xs leading-snug text-muted-foreground [text-wrap:balance]",children:aC}):null]}):null]}),(0,r.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4 shadow-card sm:p-6",children:[(0,r.jsx)("p",{className:(0,L.cn)(eh,"mb-4"),children:"What's included"}),(0,r.jsx)(em.U,{})]})]})})}default:return null}})(e.id)})},e.id)})})]})]})]}),aD]})}},69147:(e,a,t)=>{t.d(a,{Xq:()=>l});var r=t(41463);let s=null,i="https://app.baxo.ai";function l(){return s||(s=function(e){if(!e||""===e.trim())return i;let a=e.trim();return/localhost|127\.0\.0\.1/i.test(a)?(r.env.NEXT_PUBLIC_ALLOW_LOCALHOST_URL,i):(a=(a=a.replace(/bax\.team/gi,"baxo.ai")).replace(/(?<![o])bax\.ai/gi,"baxo.ai"),/^https?:\/\//i.test(a)||(a=`https://${a}`),a.replace(/\/$/,""))}("https://app.baxo.ai"))}},81477:(e,a,t)=>{t.d(a,{BT:()=>d,Wu:()=>c,ZB:()=>o,Zp:()=>l,aR:()=>n});var r=t(95155),s=t(12115),i=t(40980);let l=s.forwardRef(({className:e,...a},t)=>(0,r.jsx)("div",{ref:t,className:(0,i.cn)("rounded-xl border border-border bg-card text-card-foreground shadow",e),...a}));
1l.displayName="Card";let n=s.forwardRef(({className:e,...a},t)=>(0,r.jsx)("div",{ref:t,className:(0,i.cn)("flex flex-col space-y-1.5 p-6",e),...a}));n.displayName="CardHeader";let o=s.forwardRef(({className:e,...a},t)=>(0,r.jsx)("div",{ref:t,className:(0,i.cn)("font-semibold leading-none tracking-tight",e),...a}));o.displayName="CardTitle";let d=s.forwardRef(({className:e,...a},t)=>(0,r.jsx)("div",{ref:t,className:(0,i.cn)("text-sm text-muted-foreground",e),...a}));d.displayName="CardDescription";let c=s.forwardRef(({className:e,...a},t)=>(0,r.jsx)("div",{ref:t,className:(0,i.cn)("p-6 pt-0",e),...a}));c.displayName="CardContent",s.forwardRef(({className:e,...a},t)=>(0,r.jsx)("div",{ref:t,className:(0,i.cn)("flex items-center p-6 pt-0",e),...a})).displayName="CardFooter"},84507:(e,a,t)=>{t.d(a,{JP:()=>l,zb:()=>i});var r=t(95155),s=t(38346);function i({children:e,requiredPermission:a,requiredRole:t,fallback:l=null,showForGuests:n=!1}){let{role:o,hasPermission:d,isHigherRole:c,loading:u}=(0,s.h)();return u?(0,r.jsx)(r.Fragment,{children:l}):n&&!o?(0,r.jsx)(r.Fragment,{children:e}):(o||n)&&(!a||d(a))&&(!t||(Array.isArray(t)?t:[t]).some(e=>o===e||c(o,e)))?(0,r.jsx)(r.Fragment,{children:e}):(0,r.jsx)(r.Fragment,{children:l})}function l({permission:e,children:a,fallback:t=null}){return(0,r.jsx)(i,{requiredPermission:e,fallback:t,children:a})}},87874:(e,a,t)=>{t.d(a,{F9:()=>u,OG:()=>c,WM:()=>s});var r=t(41463);let s="comped",i=new Set(["5245935a-3acc-4f90-9ca4-1034ab143234","d91bfa2b-35ed-4a9d-bc34-a6ef52c3299a","651e4c82-16f2-46cc-940a-20d51a4742fb"]),l=new Set(["davidgreenco"]);function n(e){return new Set((e??"").split(",").map(e=>e.trim().toLowerCase()).filter(Boolean))}let o=n(r.env.BAXO_COMPED_WORKSPACE_IDS),d=n(r.env.BAXO_COMPED_WORKSPACE_HANDLES);function c(e){return"active"===e||"trialing"===e||e===s}function u(e){if(!e)return!1;if(e.subscription_status===s)return!0;let a=e.id?.trim().toLowerCase();if(a&&(i.has(a)||o.has(a)))return!0;let t=e.handle?.trim().toLowerCase();return!!(t&&(l.has(t)||d.has(t)))}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.