PageSourceSearch

https://studio.findem.ai/assets/Account-CiGUcrxb.js

js findem.ai collected 2026-09-24 19:16:22 UTC 9,508 bytes, 1 lines download raw bytes

1import{u as $,j as e,bQ as B,cv as M,bJ as q,a as H,r as i,cV as C,cW as Y,cX as J,cY as Q,cZ as F,Q as A,c_ as O,am as V,bD as z,a1 as K,c$ as U,N as X,B as S,d as Z,C as ee}from"./index-C-_Qp0pL.js";import{C as te}from"./copy-SST6cGDg.js";const h="grid gap-x-6 gap-y-2 border-b border-paper-border py-3.5 sm:grid-cols-[minmax(0,220px)_minmax(0,1fr)] sm:items-center";function se({auth:s,api:y=Y}){const[a,x]=i.useState(()=>C(s.user)),[m,k]=i.useState(null),[l,w]=i.useState(!0),[o,b]=i.useState(!1),[v,f]=i.useState(""),[j,c]=i.useState(""),[N,p]=i.useState(0),[g,d]=i.useState(!1),u=i.useRef(null),E=i.useRef(null),P=()=>{d(!1),E.current?.focus()};i.useEffect(()=>{if(!g)return;const t=n=>{u.current&&!u.current.contains(n.target)&&d(!1)},r=n=>{n.key==="Escape"&&(n.preventDefault(),P())};return u.current?.querySelector('[aria-pressed="true"]')?.focus(),window.addEventListener("mousedown",t),window.addEventListener("keydown",r),()=>{window.removeEventListener("mousedown",t),window.removeEventListener("keydown",r)}},[g]),i.useEffect(()=>{let t=!0;return w(!0),f(""),y.get().then(({profile:r})=>{if(!t)return;if(r?.user_id!==s.user.id)throw new Error("We could not verify your profile. Please retry.");const n=C(s.user,r);x(n),k(n)}).catch(r=>{t&&f(r.status===404?"Account preferences are not available on this server yet.":r.message||"Could not load your profile.")}).finally(()=>{t&&w(!1)}),()=>{t=!1}},[y,s.user.id,N]);const _=(t,r)=>{c(""),x(n=>({...n,[t]:r,...t==="work_category"&&r!=="other"?{work_title:""}:{}}))},R=m&&JSON.stringify(a)!==JSON.stringify(m),D=a.display_name.trim()&&(a.work_category!=="other"||a.work_title.trim());async function G(t){if(t.preventDefault(),!(!m||!R||!D||o)){b(!0),f(""),c("");try{const r={...a,display_name:a.display_name.trim(),work_title:a.work_title.trim()},{profile:n}=await y.save(r);if(n?.user_id!==s.user.id)throw new Error("We could not verify the saved profile. Please reload.");const W=C(s.user,n);x(W),k(W),s.updateAccountProfile?.(n),c("Profile saved.")}catch(r){f(r.message||"Could not save your profile. Your changes are still here.")}finally{b(!1)}}}const L=J({name:a.display_name,email:s.user.email}),I=Q(a.avatar_glyph)||"initials",T=F.find(t=>t.id===I);return e.jsx(e.Fragment,{children:e.jsxs("form",{onSubmit:G,"aria-labelledby":"account-about-heading","aria-busy":l||o,children:[e.jsx("h2",{id:"account-about-heading",className:"text-base font-semibold text-ink",children:"About you"}),e.jsxs("div",{className:h,children:[e.jsx("p",{className:"text-sm font-medium text-ink",children:"Avatar"}),e.jsxs("div",{ref:u,className:"relative flex items-center",children:[e.jsxs("button",{ref:E,type:"button","aria-haspopup":"true","aria-expanded":g,"aria-label":`Change avatar, currently ${T?.label||"Initials"}`,disabled:l||o,onClick:()=>d(t=>!t),className:`group relative flex h-12 w-12 shrink-0 items-center justify-center rounded-full text-sm font-semibold disabled:opacity-60 ${A.accountAvatar}`,children:[e.jsx(O,{glyph:a.avatar_glyph,fallback:L,size:24}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 grid place-items-center rounded-full bg-ink/45 text-white opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100",children:e.jsx(V,{size:15,strokeWidth:2.2})})]}),g?e.jsx("div",{role:"group","aria-label":"Choose your avatar",className:"absolute left-0 top-[calc(100%+8px)] z-20 flex w-[248px] flex-wrap gap-1.5 rounded-xl border border-paper-border bg-white p-2 shadow-[0_18px_48px_rgba(0,0,0,0.18)]",children:F.map(t=>{const r=I===t.id;return e.jsx("button",{type:"button","aria-label":t.label,"aria-pressed":r,title:t.label,onClick:()=>{_("avatar_glyph",t.id),P()},className:`flex h-9 w-9 items-center justify-center rounded-[9px] text-[11px] font-semibold transition-colors ${r?A.accountAvatar:A.accountAvatarChoice}`,children:e.jsx(O,{glyph:t.id,fallback:L,size:18})},t.id)})}):null]})]}),e.jsxs("div",{className:h,children:[e.jsx("label",{htmlFor:"account-name",className:"text-sm font-medium text-ink",children:"Your name"}),e.jsx(z,{id:"account-name",name:"display_name",theme:"studio",value:a.display_name,required:!0,maxLength:120,autoComplete:"name",disabled:l||o,onChange:t=>_("display_name",t.target.value)})]}),e.jsxs("div",{className:h,children:[e.jsx("label",{htmlFor:"account-work",className:"text-sm font-medium text-ink",children:"What best describes your work?"}),e.jsxs(K,{id:"account-work",name:"work_category",theme:"studio",value:a.work_category,disabled:l||o,onChange:t=>_("work_category",t.target.value),children:[e.jsx("option",{value:"",children:"Select your work"}),U.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))]})]}),a.work_category==="other"?e.jsxs("div",{className:h,children:[e.jsx("label",{htmlFor:"account-work-title",className:"text-sm font-medium text-ink",children:"Your work or job title"}),e.jsx(z,{id:"account-work-title",theme:"studio",name:"work_title",placeholder:"e.g. Product designer",value:a.work_title,required:!0,maxLength:120,disabled:l||o,onChange:t=>_("work_title",t.target.value)})]}):null,l?e.jsx("p",{role:"status",className:"mt-4 text-sm text-ink-soft",children:"Loading your profile…"}
1):null,v?e.jsxs(X,{role:"alert",tone:"danger",className:"mt-4",children:[v,m?null:e.jsx(S,{theme:"studio",size:"sm",className:"ml-3",onClick:()=>p(t=>t+1),children:"Retry"})]}):null,j?e.jsx("p",{role:"status",className:"mt-4 text-sm text-ink-soft",children:j}):null,R?e.jsxs("div",{className:"mt-5 flex flex-wrap justify-end gap-3",children:[e.jsx(S,{theme:"studio",disabled:o,onClick:()=>{x(m),f(""),c("")},children:"Cancel"}),e.jsx(S,{theme:"studio",type:"submit",variant:"primary",disabled:!D||o||l,loading:o,children:"Save changes"})]}):null]})})}function ae({auth:s,api:y=Y}){const a=s.mcpScopeOrg?.mcp_org_id,[x,m]=i.useState(null),[k,l]=i.useState(""),[w,o]=i.useState(!1),[b,v]=i.useState(""),[f,j]=i.useState(0);if(i.useEffect(()=>{if(!a||s.isPersonalMcpScope)return;let d=!0;return m(null),l(""),o(!1),v(""),y.workspace(a).then(u=>{if(d){if(u?.mcp_org_id!==a)throw new Error("Workspace details could not be verified.");m(u)}}).catch(u=>{d&&l(u.message||"Could not load workspace details.")}),()=>{d=!1}},[y,s.user.id,a,s.isPersonalMcpScope,f]),!a||s.isPersonalMcpScope)return null;const c=x?.mcp_org_id===a?x:null,N=c||s.mcpScopeOrg,p=c?c.primary_owner:s.mcpScopeOrg.is_primary_owner?{name:s.user.name,email:s.user.email,is_you:!0}:null,g=N?.is_primary_owner?"Primary owner":{owner:"Owner",admin:"Admin",member:"Member"}[N?.role]||"Not available";return e.jsxs("section",{className:"pt-7","aria-labelledby":"account-workspace-heading",children:[e.jsxs("h2",{id:"account-workspace-heading",className:"text-base font-semibold text-ink",children:["Current workspace: ",e.jsx("span",{className:"font-medium text-ink-soft",children:s.mcpScopeLabel})]}),e.jsx("p",{className:"mt-1.5 text-sm text-ink-soft",children:"These apply only while you are in this workspace. Your profile above follows you everywhere."}),e.jsxs("dl",{className:"mt-2",children:[e.jsxs("div",{className:h,children:[e.jsx("dt",{className:"text-sm font-medium text-ink",children:"Your role"}),e.jsx("dd",{className:"sm:text-right",children:e.jsx(Z,{theme:"studio",children:g})})]}),e.jsxs("div",{className:h,children:[e.jsx("dt",{className:"text-sm font-medium text-ink",children:"Primary owner"}),e.jsx("dd",{className:"min-w-0 text-sm sm:text-right",children:p?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-ink",children:p.is_you?`${s.user.name||p.name||"You"} (you)`:p.name||"Primary owner"}),p.email?e.jsx("p",{className:"break-all text-ink-soft",children:p.email}):null]}):k?e.jsxs(e.Fragment,{children:[e.jsx("p",{role:"alert",className:"text-ink-soft",children:"Could not load the primary owner."}),e.jsx(S,{theme:"studio",className:"mt-2",size:"sm",onClick:()=>j(d=>d+1),children:"Retry"})]}):e.jsx("span",{role:c?void 0:"status",className:"text-ink-soft",children:c?"Not available":"Loading owner details…"})})]}),e.jsxs("div",{className:h,children:[e.jsx("dt",{className:"text-sm font-medium text-ink",children:"Workspace ID"}),e.jsx("dd",{className:"flex min-w-0 items-center gap-2 sm:justify-end",children:e.jsxs("button",{type:"button","aria-label":w?"Workspace ID copied":"Copy workspace ID",title:"Click to copy",onClick:async()=>{v(""),o(!1);try{await navigator.clipboard.writeText(a),o(!0)}catch{v("Could not copy. Select the workspace ID to copy it manually.")}},className:"group inline-flex min-w-0 items-center gap-1.5 rounded-md bg-paper-soft px-2 py-1 text-left font-mono text-xs text-ink-soft transition-colors hover:bg-paper-active hover:text-ink",children:[e.jsx("span",{className:"min-w-0 break-all",children:a}),w?e.jsx(ee,{size:12,className:"shrink-0 text-ink"}):e.jsx(te,{size:12,className:"shrink-0 opacity-0 transition-opacity group-hover:opacity-100"})]})})]})]}),w?e.jsx("p",{role:"status",className:"mt-2 text-xs text-ink-soft",children:"Workspace ID copied."}):null,b?e.jsx("p",{role:"alert",className:"mt-2 text-xs text-ink-soft",children:b}):null]})}function oe(){const s=$();return s.user?e.jsx(B,{children:e.jsx(M,{children:e.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[e.jsx(q,{title:"Profile",description:"How you appear across all your workspaces."}),e.jsxs(H,{theme:"studio",padding:"lg",children:[e.jsx(se,{auth:s},s.user.id),e.jsx(ae,{auth:s},`${s.user.id}:${s.mcpScopeId}`)]})]})})}):null}export{se as AccountProfileForm,ae as AccountWorkspaceDetails,oe as default};

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.