1import{n as e,o as t}from"./rolldown-runtime-CMxvf4Kt.js";import{F as n,L as r}from"../vendor/vendor-data-runtime-nLFaCKB0.js";import{Ao as i,Et as a,g as o,jo as s}from"./app-const-BzFqCjOv.js";import{Do as c,Fn as l,bo as u,go as d,to as f,vo as p,wo as m,zn as h}from"./ScrollArea-CdDxdn_v.js";import{Ka as g,Sa as _,ei as ee,fa as te,n as v,oi as y}from"./es-D7HWafs1.js";import{at as ne,b,n as x,r as re,xn as S}from"./es-D3_QMuVV.js";import{Nt as ie,Ti as ae,Vm as oe,Y_ as se,et as C,ha as ce,hn as le,rd as ue,su as de}from"../vendor/vendor-icons-BXJMWD35.js";import{O as w,n as T,r as fe}from"./base-ui-Bi3Dz7GG.js";import{r as pe}from"./store-DZ_eFvAj.js";import{n as E}from"./file-DreLu7dP.js";import{Bo as D,Io as me,Lo as O,Vo as he}from"./index-Doip7UYu.js";import{n as ge,t as k}from"./useWorkspaceAwareNavigate--pLVtz2A.js";import{n as _e,t as A}from"./useCommunityWorkspaceProfile-CPSJ04Cm.js";import{a as j,n as M,o as ve,r as ye}from"./communityWorkspaceProfile-BZAGyu1l.js";var N,P=e((()=>{N=()=>({canSync:!1,isLoading:!1,members:[],refresh:async()=>{}})})),F,I,L,R,be,xe,Se,Ce,we,z,B,V,H,U,W,Te,G,K=e((()=>{o(),v(),T(),x(),u(),C(),F=t(s()),n(),P(),A(),M(),O(),k(),D(),E(),I=t(i()),L=2*1024*1024,R=32,be=3,xe=200,Se=50,Ce=`${a.replace(/^https?:\/\//,``)}/community/org/`,we=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,z=m(({css:e,cssVar:t})=>({footer:e` 2 padding-block: 12px; 3 padding-inline: 20px; 4 border-block-start: 1px solid ${t.colorFillTertiary}; 5 background: ${t.colorFillQuaternary}; 6 `,hint:e` 7 font-size: 13px; 8 color: ${t.colorTextSecondary}; 9 `,memberNameLink:e` 10 color: inherit; 11 12 &:hover { 13 color: ${t.colorPrimary}; 14 } 15 `})),B=e=>!!e&&/[A-Z]/.test(e),V=(0,F.memo)(({title:e,description:t,children:n,hint:r,action:i})=>(0,I.jsxs)(g,{variant:`outlined`,children:[(0,I.jsxs)(p,{gap:12,padding:20,children:[(0,I.jsxs)(p,{gap:4,children:[(0,I.jsx)(l,{strong:!0,as:`h3`,style:{fontSize:16,margin:0},children:e}),t&&(0,I.jsx)(l,{style:{fontSize:13},type:`secondary`,children:t})]}),n]}),(r||i)&&(0,I.jsxs)(p,{horizontal:!0,align:`center`,className:z.footer,gap:12,justify:`space-between`,children:[(0,I.jsx)(`span`,{className:z.hint,children:r??``}),i]})]})),V.displayName=`CommunityWorkspaceSettingCard`,H=(0,F.memo)(({children:e})=>(0,I.jsx)(p,{height:`100%`,style:{overflowX:`hidden`,overflowY:`auto`},width:`100%`,children:(0,I.jsx)(p,{gap:16,padding:24,style:{boxSizing:`border-box`,margin:`0 auto`,maxWidth:1200,width:`100%`},children:e})})),H.displayName=`CommunityWorkspaceSettingsPageContainer`,U=(0,F.memo)(({canManage:e})=>{let{t}=r(`discover`),{message:n}=S.useApp(),{canSync:i,isLoading:a,members:o,refresh:s}=N(),[c,u]=(0,F.useState)(!1),d=e&&i,f=(0,F.useCallback)(async()=>{u(!0);try{await j(),await s(),n.success(t(`user.workspaceProfile.settings.members.syncSuccess`))}catch(e){n.error(e.message||t(`user.workspaceProfile.settings.members.syncFailed`))}finally{u(!1)}},[n,s,t]),m=(0,F.useMemo)(()=>[{dataIndex:`displayName`,render:(e,t)=>{let n=t.displayName||t.userName||t.namespace||`#${t.accountId}`,r=t.userName||(t.namespace&&!B(t.namespace)?t.namespace:null),i=r||t.namespace,a=i?`/community/user/${i}`:void 0,o=(0,I.jsx)(l,{strong:!0,style:{fontSize:14},children:n});return(0,I.jsxs)(p,{horizontal:!0,align:`center`,gap:12,children:[(0,I.jsx)(_,{avatar:t.avatarUrl||void 0,size:36,title:n}),(0,I.jsxs)(p,{gap:2,children:[a?(0,I.jsx)(`a`,{className:z.memberNameLink,href:a,rel:`noopener noreferrer`,target:`_blank`,children:o}):o,r&&a&&(0,I.jsx)(`a`,{className:z.memberNameLink,href:a,rel:`noopener noreferrer`,target:`_blank`,children:(0,I.jsxs)(l,{style:{fontSize:12},type:`secondary`,children:[`@`,r]})})]})]})},title:t(`user.workspaceProfile.settings.members.column.member`)},{align:`left`,dataIndex:`role`,onCell:()=>({style:{verticalAlign:`middle`}}),render:e=>(0,I.jsx)(te,{children:t(e===`admin`?`user.workspaceProfile.settings.members.role.admin`:`user.workspaceProfile.settings.members.role.member`)}),title:t(`user.workspaceProfile.settings.members.column.role`),width:120}],[t]);return(0,I.jsx)(V,{description:t(`user.workspaceProfile.settings.members.description`),hint:t(`user.workspaceProfile.settings.members.syncHint`),title:t(`user.workspaceProfile.settings.members.title`),action:(0,I.jsx)(w,{disabled:!d,icon:ce,loading:c,onClick:f,children:t(`user.workspaceProfile.settings.members.sync`)}),children:(0,I.jsx)(b,{columns:m,dataSource:o,loading:a&&o.length===0,pagination:!1,rowKey:`accountId`,size:`middle`,locale:{emptyText:(0,I.jsx)(l,{style:{fontSize:13},type:`secondary`,children:t(`user.workspaceProfile.settings.members.empty`)})}})})}),U.displayName=`CommunityWorkspaceMembersCard`,W=e=>e?.trim()||void 0,Te=e=>{if(!e.trim())return!0;try{let{protocol:t}=new URL(e.trim());return t===`http:`||t===`https:`}catch{return!1}},G=(0,F.memo)(()=>{let{t:e}=r(`discover`),{message:t}=S.useApp(),n=ge(),{allowed:i,reason:a}=he(`manage_settings`),o=pe(e=>e.uploadWithProgress),{avatarUrl:s,bannerUrl:u,canEdit:m,description:g,displayName:_,isLoading:te,profile:v,refresh:b,username:x}=_e(),C=i&&m&&!!v,ce=i?e(`user.workspaceProfile.settings.noPermission`):a,[T,E]=(0,F.useState)(_??``),[D,O]=(0,F.useState)(x??``),[k,A]=(0,F.useState)(g??``),[j,M]=(0,F.useState)(v?.websiteUrl??``),[N,P]=(0,F.useState)(s??null),[z,B]=(0,F.useState)(u??null),[G,K]=(0,F.useState)(null),[q,Ee]=(0,F.useState)(!1),[De,Oe]=(0,F.useState)(!1),[ke,J]=(0,F.useState)(),[Y,Ae]=(0,F.useState)(),[X,je]=(0,F.useState)(`profile`),Me=(0,F.useCallback)(()=>
15{if(window.history.length>1){n(-1);return}n(`/community/workspace`)},[n]),Ne=()=>(0,I.jsx)(p,{horizontal:!0,align:`center`,gap:8,children:(0,I.jsx)(w,{icon:se,type:`text`,onClick:Me,children:e(`user.workspaceProfile.settings.back`)})});(0,F.useEffect)(()=>{E(_??``),O(x??``),A(g??``),M(v?.websiteUrl??``),P(s??null),B(u??null),J(void 0),Ae(void 0)},[v?.accountId,v?.websiteUrl,s,u,g,_,x]);let Z=(0,F.useCallback)(async(n,r)=>{if(C){K(n);try{await ve(r),await b(),t.success(e(`user.workspaceProfile.settings.updateSuccess`))}catch(r){n===`namespace`&&ye(r)?J(e(`user.workspaceProfile.settings.namespaceTaken`)):t.error(r.message||e(`user.workspaceProfile.settings.updateFailed`))}finally{K(null)}}},[C,t,b,e]),Q=(t,n,r)=>{let i=(0,I.jsx)(w,{disabled:!C||n||te,loading:G===t,type:`primary`,onClick:r,children:e(`user.workspaceProfile.save`)});return C?i:(0,I.jsx)(h,{title:ce,children:(0,I.jsx)(`span`,{children:i})})},$=(0,F.useMemo)(()=>{let t=D.trim();return t?t.length<be||t.length>R?e(`user.workspaceProfile.errors.namespace.length`):we.test(t)?ke:e(`user.workspaceProfile.errors.namespace.pattern`):e(`user.workspaceProfile.errors.namespace.required`)},[D,ke,e]),Pe=(0,F.useCallback)(async n=>{if(n.size>L){t.error(e(`user.workspaceProfile.errors.fileTooLarge`));return}Ee(!0);try{let r=await o({file:n});if(!r?.url){t.error(e(`user.workspaceProfile.errors.uploadFailed`));return}P(r.url.startsWith(`/`)?`${window.location.origin}${r.url}`:r.url)}catch(n){console.error(`[CommunityWorkspaceSettings] Avatar upload failed:`,n),t.error(e(`user.workspaceProfile.errors.uploadFailed`))}finally{Ee(!1)}},[t,e,o]),Fe=(0,F.useCallback)(async n=>{let r=n.file;if(r.size>L){t.error(e(`user.workspaceProfile.errors.fileTooLarge`)),n.onError?.(Error(`File too large`));return}Oe(!0);try{let i=await o({file:r});if(!i?.url){t.error(e(`user.workspaceProfile.errors.uploadFailed`)),n.onError?.(Error(`Upload failed`));return}B(i.url.startsWith(`/`)?`${window.location.origin}${i.url}`:i.url),n.onSuccess?.(i)}catch(r){console.error(`[CommunityWorkspaceSettings] Banner upload failed:`,r),t.error(e(`user.workspaceProfile.errors.uploadFailed`)),n.onError?.(r)}finally{Oe(!1)}},[t,e,o]);if(!v)return(0,I.jsx)(H,{children:Ne()});let Ie=T.trim()!==(_??``),Le=D.trim()!==(x??``),Re=k.trim()!==(g??``),ze=j.trim()!==(v.websiteUrl??``),Be=N!==(s??null),Ve=z!==(u??null);return(0,I.jsxs)(H,{children:[Ne(),(0,I.jsx)(fe,{activeKey:X,items:[{icon:(0,I.jsx)(f,{icon:ae,size:16}),key:`profile`,label:e(`user.workspaceProfile.settings.tabs.profile`)},{icon:(0,I.jsx)(f,{icon:ie,size:16}),key:`members`,label:e(`user.workspaceProfile.settings.tabs.members`)}],onChange:e=>je(e)}),X===`members`&&(0,I.jsx)(U,{canManage:i}),X===`profile`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(V,{description:e(`user.workspaceProfile.settings.displayName.description`),hint:e(`user.workspaceProfile.fields.displayName.maxLength`),title:e(`user.workspaceProfile.fields.displayName`),action:Q(`displayName`,!Ie||!T.trim(),()=>Z(`displayName`,{displayName:T.trim()})),children:(0,I.jsx)(y,{showCount:!0,disabled:!C,maxLength:Se,style:{maxWidth:420},value:T,onChange:e=>E(e.target.value)})}),(0,I.jsx)(V,{description:e(`user.workspaceProfile.settings.namespace.description`),title:e(`user.workspaceProfile.fields.namespace`),action:Q(`namespace`,!Le||!!$,()=>Z(`namespace`,{namespace:D.trim()})),hint:$||e(`user.workspaceProfile.settings.namespace.hint`,{max:R}),children:(0,I.jsx)(ne,{showCount:!0,addonBefore:Ce,disabled:!C,maxLength:R,status:$?`error`:void 0,style:{maxWidth:560},value:D,onChange:e=>{O(e.target.value),J(void 0)}})}),(0,I.jsx)(V,{description:e(`user.workspaceProfile.settings.description.description`),hint:e(`user.workspaceProfile.fields.description.maxLength`),title:e(`user.workspaceProfile.fields.description`),action:Q(`description`,!Re,()=>Z(`description`,{description:W(k)})),children:(0,I.jsx)(ee,{showCount:!0,disabled:!C,maxLength:xe,rows:3,style:{maxWidth:560},value:k,onChange:e=>A(e.target.value)})}),(0,I.jsx)(V,{description:e(`user.workspaceProfile.settings.website.description`),hint:Y||e(`user.workspaceProfile.settings.website.hint`),title:e(`user.workspaceProfile.fields.websiteUrl`),action:Q(`websiteUrl`,!ze||!!Y,()=>Z(`websiteUrl`,{websiteUrl:W(j)})),children:(0,I.jsx)(y,{disabled:!C,status:Y?`error`:void 0,style:{maxWidth:560},value:j,prefix:(0,I.jsx)(f,{color:c.colorTextSecondary,icon:ue,style:{marginRight:8}}),onChange:t=>{let n=t.target.value;M(n),Ae(Te(n)?void 0:e(`user.workspaceProfile.errors.url`))}})}),(0,I.jsx)(V,{description:e(`user.workspaceProfile.settings.avatar.description`),hint:e(`user.workspaceProfile.settings.avatar.hint`),title:e(`user.workspaceProfile.fields.avatar`),action:Q(`avatarUrl`,!Be||q,()=>Z(`avatarUrl`,{avatarUrl:N})),children:(0,I.jsx)(me,{allowDelete:C&&!!N,allowUpload:C?{enableEmoji:!0}:!1,loading:q,shape:`square`,size:80,value:N||void 0,onDelete:C?()=>P(null):void 0,onUpload:C?Pe:void 0,onChange:C?e=>{e.startsWith(`data:`)||P(e||null)}:void 0})}),(0,I.jsx)(V,{description:e(`user.workspaceProfile.settings.banner.description`),hint:e(`user.workspaceProfile.fields.bannerUrl.tooltip`),action:Q(`bannerUrl`,!Ve||De,()=>Z(`bannerUrl`,{bannerUrl:z})),title:(0,I.jsxs)(p,{horizontal:!0,align:`center`,gap:4,children:[e(`user.workspaceProfile.fields.bannerUrl`),(0,I.jsx)(h,{title:e(`user.workspaceProfile.fields.bannerUrl.tooltip`),children:(0,I.jsx)(oe,{size:14,style:{cursor:`help`,opacity:.5}})})]}),children:(0,I.jsxs)(p,{gap:8,width:`100%`,children:[(0,I.jsx)(re,{accept:`image/*`,customRequest:Fe,disabled:!C,maxCount:1,showUploadList:!1,style:{display:`block`,width:`100%`},children:(0,I.jsx)(`div`,{style:{backgroundColor:z?void 0:c.colorFillTertiary,backgroundImage:z?`url(${z})`:void 0,backgroundPosition:`center`,backgroundSize:`cover`,borderRadius:c.borderRadiusLG,cursor:C?`pointer`:`not-allowed`,height:160,maxWidth:560,overflow:`hidden`,position:`relative`,width:`100%`},children:(0,I.jsx)(d,{style:{background:z?`rgba(0,0,0,0.4)`:`transparent`,height:`100%`,opacity:+!z,transition:`opacity 0.2s`,width:`100%`},onMouseEnter:e=>{C&&(e.currentTarget.style.opacity=`1`)},onMouseLeave:e=>{C&&z&&(e.currentTarget.style.opacity=`0`)},children:(0,I.jsxs)(p,{align:`center`,gap:8,children:[(0,I.jsx)(de,{size:24,style:{color:z?`#fff`:c.colorTextSecondary}}),(0,I.jsx)(l,{style:{color:z?`#fff`:c.colorTextSecondary,fontSize:12},children:e(De?`user.workspaceProfile.fields.bannerUrl.uploading`:`user.workspaceProfile.fields.bannerUrl.clickToUpload`)})]})})})}),C&&z&&(0,I.jsx)(p,{horizontal:!0,align:`center`,gap:8,justify:`flex-start`,children:(0,I.jsx)(w,{danger:!0,icon:(0,I.jsx)(le,{size:12}),size:`small`,type:`text`,onClick:()=>B(null),children:e(`user.workspaceProfile.fields.bannerUrl.remove`)})})]})})]})]})}
15),G.displayName=`CommunityWorkspaceSettings`})),q;e((()=>{K(),q=G}))();export{q 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.