decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines • 59.2 kB
JavaScript
import{aJ as qe,bF as ae,aK as W,ct as Ge,dD as Xe,c as Y,a6 as Ye,ho as He,i as nt,j as s,b as ee,q as it,r as F,aI as Pt,aH as Dt,e as rt,t as Le,K as Ne,E as Qe,dQ as Lt,C as Mt,n as se,m as q,ai as at,B as re,P as wt,h as we,gZ as et,gl as tt,gm as st,a7 as yt,hk as ct,o as dt,b8 as lt,av as vt,aR as mt,aQ as ut,aL as ft,aM as gt,aN as _t,aO as Et,bc as Tt,aP as At,ay as Gt,u as It,i9 as ht,id as kt,R as Bt,d as Ut,_ as Kt,X as Vt,Z as Ft,Y as zt}from"./index-DoEtSiIe.js";import{g as Rt,a as Yt,P as Ke,l as Ht,b as Qt,C as Ve,d as $t,p as Zt,c as Jt,e as Wt,u as qt}from"./role-color-BX_AhYik.js";import{B as Me}from"./badge-DONoxQO7.js";import{a as Xt}from"./SwitchHorizontal01-CHtrDs50.js";import{s as Fe}from"./Plus-BoPsX_T8.js";import{s as es}from"./Trash01-Ctp9Olbr.js";import{C as ts}from"./collection-table-wrapper-fYA2bGN6.js";import{E as ot}from"./empty-state-C4MgLcBg.js";import{S as $e}from"./search-input-wk0beNbE.js";import{P as pt,D as xt}from"./ai-providers-logos-DD3qZ33J.js";import{a as ss}from"./tool-set-selector-WN2Xo0Mj.js";import{b as St}from"./use-connection-BO-ZUzee.js";import{d as ls}from"./repository-binding-BAQCDq-W.js";import{u as os,h as ns}from"./use-ai-providers-BwkzkRi2.js";import{C as Ze}from"./checkbox-CkODjqKt.js";import{S as ce}from"./switch-C5tCt-1T.js";import{b as be,c as je,T as Pe,a as De}from"./tooltip-DhlWzeQv.js";import{I as Ot}from"./integration-icon-DvT6X8cI.js";import{P as is}from"./project-icon-BxqBM24K.js";import{s as rs}from"./use-project-scope-AMUoXt2c.js";import{t as as}from"./Globe04-5yHQa01g.js";import{t as cs}from"./ChevronDown-Dm2xO7jf.js";import{b3 as ds,k as ms}from"./agent-icon-DoabtHNW.js";import{A as us}from"./access-gate-4Yp7vAaA.js";import"./table-RDPVkrI6.js";import"./ArrowUp-s5a8DQxj.js";import"./SearchMd-BGRe_18c.js";import"./use-infinite-scroll-uxxC9xbL.js";import"./ArrowLeft-DuGHc_Gh.js";import"./useSuspenseInfiniteQuery-CucINu-S.js";import"./infiniteQueryObserver-BRGiYBJv.js";import"./use-mcp-client-86j-Nolb.js";import"./auth-IBAsOARn.js";import"./collection-search-DL8nJQx4.js";import"./connection-BxF6Rdiu.js";import"./url-slug-CiUrNKts.js";import"./Minus-CFYZtYi9.js";import"./index-BFFHlwFA.js";import"./LinkBroken01-CyjdgWmP.js";import"./AlertCircle-GoAGGV0G.js";import"./UserCheck01-CA8kXGn8.js";import"./Tool01-D90Wr5xR.js";import"./ArrowRight-CMJyKdyB.js";import"./BookOpen01-DZs1-yi9.js";import"./CheckCircle-vIQcB0iT.js";import"./ChevronSelectorVertical-Cvgyclsz.js";import"./ChevronUp-BKdcyIOm.js";import"./UserSquare-dgrNjiXb.js";import"./CreditCard01-BUXydXso.js";import"./File02-Y4Nh84qP.js";import"./MessageCircle01-zc37Krdu.js";import"./Eye-DwRCQHLk.js";import"./Fingerprint04-DlIWxzRc.js";import"./Image01-BRABRo3v.js";import"./Key01-DfLmV_su.js";import"./LayoutLeft-owMYqid0.js";import"./Monitor01-DUhT2Mcw.js";import"./Sun-uwKn4QPm.js";import"./Play-C_9Fb_Ik.js";import"./ShoppingBag01-CoN4FBW5.js";import"./Upload01-DgxprpI7.js";import"./Users01-BasqfwpC.js";import"./XClose-BUxhnZ3x.js";import"./Zap-CxPsn4FS.js";import"./capability-load-error-C6JoLBp9.js";const Je="basic-usage",We=[{id:Je,label:"Basic Usage",description:"Tools all org members can access by default",section:"Basic Usage",tools:["CODEX_SUBSCRIPTION_CONNECT","CODEX_SUBSCRIPTION_STATUS","SUBSCRIPTION_USAGE_GET","CODEX_SUBSCRIPTION_DISCONNECT","CODEX_SUBSCRIPTION_SYNC","COLLECTION_CONNECTIONS_LIST","COLLECTION_CONNECTIONS_GET","CONNECTION_TEST","CONNECTION_TOOLS_SEARCH","CONNECTION_TOOL_CALL","COLLECTION_VIRTUAL_MCP_LIST","COLLECTION_VIRTUAL_MCP_GET","VIRTUAL_MCP_LAST_USED_LIST","SIDEBAR_GET","SIDEBAR_PREFERENCES_SET","PROJECT_FOLDER_ENSURE","AUTOMATION_GET","AUTOMATION_LIST","AUTOMATION_RUN_STATS","AI_PROVIDERS_LIST","AI_PROVIDERS_LIST_MODELS","AI_PROVIDERS_ACTIVE","AI_PROVIDER_KEY_LIST","AI_PROVIDER_CREDITS","AI_PLAN_ENTITLEMENTS","AI_PLAN_LIST","ORGANIZATION_BILLING_PLAN_PRICES","AI_PROVIDER_TOPUP_URL","LIST_OBJECTS","GET_OBJECT_METADATA","GET_PRESIGNED_URL","PUT_PRESIGNED_URL","FILE_CONFIG_LIST","FILE_OBJECTS_LIST","ORG_REPO_SYNC_LIST","SANDBOX_START","SANDBOX_DELETE","THREAD_SANDBOX_START","REPOSITORY_SEARCH_BRANCHES","GIT_PROVIDER_CAPABILITIES","GIT_ACCOUNT_LIST","REPOSITORY_LIST","REPOSITORY_SEARCH","CHANGE_REQUEST_STATE","CHANGE_REQUEST_LAST_MERGED","CHANGE_REQUEST_LIST_OPEN","CHANGE_REQUEST_CHECK_LOG","GLOBAL_SEARCH","ORGANIZATION_SETTINGS_GET","USER_GET","ORGANIZATION_HAS_SITE","ORGANIZATION_BLOCKS_EDITOR_SET","ORGANIZATION_PLAN_OBJECTIVE_SET","ORGANIZATION_PLAN_OBJECTIVE_FIND","PLAN_CASE_NEXT_QUESTION","COLLECTION_THREADS_CREATE","COLLECTION_THREADS_LIST","COLLECTION_THREADS_GET","COLLECTION_THREADS_UPDATE","COLLECTION_THREADS_DELETE","COLLECTION_THREAD_MESSAGES_LIST","TASK_BOARD_ITEM_CREATE","TASK_BOARD_ITEM_LIST","TASK_BOARD_ITEM_UPDATE","TASK_BOARD_ITEM_DELETE","TASK_BOARD_PROMPT_LIST","TASK_BOARD_PROMPT_UPSERT","TASK_BOARD_PROMPT_DELETE","TASK_BOARD_ITEM_PRS_GET","TASK_BOARD_PREVIEW_PROBE","ANALYTICS_INSTALL","TASK_BOARD_ITEM_RERUN","TASK_BOARD_RUN_REVIEWER","TASK_BOARD_REVIEW_DECISION","TASK_BOARD_PROMOTE_TO_PRODUCTION","TASK_BOARD_ACTIVITY_LIST","TASK_BOARD_COMMENT_LIST","TASK_BOARD_COMMENT_CREATE","TASK_BOARD_COMMENT_UPDATE","TASK_BOARD_COMMENT_DELETE","TASK_BOARD_DISMISSED_LIST","TASK_BOARD_DISMISSED_RESTORE","TASK_BOARD_SPRINT_LIST","TASK_BOARD_SPRINT_CREATE","TASK_BOARD_SPRINT_UPDATE","TASK_BOARD_SPRINT_START","TASK_BOARD_SPRINT_COMPLETE","TASK_BOARD_SPRINT_DELETE","TASK_BOARD_ADMIN_ORG_LIST","TASK_BOARD_DELIVERY","TASK_BOARD_OPERATION","TASK_BOARD_OPERATION_TASKS","TASK_BOARD_REWORK","TASK_BOARD_SPRINTS","TASK_BOARD_STUCK","TASK_BOARD_COST","TASK_BOARD_QUALITY","TASK_BOARD_ERRORS","TASK_BOARD_TENANTS","THREAD_ANALYTICS_ORG_LIST","THREAD_ANALYTICS_LIVE","THREAD_ANALYTICS_USAGE","THREAD_ANALYTICS_ERRORS","NOTIFICATION_LIST","NOTIFICATION_MARK_READ","NOTIFICATION_SUBSCRIPTION_SET","NOTIFICATION_SUBSCRIPTION_LIST","ALERTS_LIST","ALERT_ACK","ALERT_RULES_LIST","ALERT_RULE_UPDATE","generate_image","generate_text","web_search","deep_research","suggest_task","preview_navigate","update_interests"]},{id:"org:manage",label:"Manage organization",description:"Edit organization settings and domain configuration",section:"Organization",tools:["ORGANIZATION_GET","ORGANIZATION_LIST","ORGANIZATION_UPDATE","ORGANIZATION_SETTINGS_GET","ORGANIZATION_SETTINGS_UPDATE","ORGANIZATION_DOMAIN_LIST","ORGANIZATION_DOMAIN_ADD","ORGANIZATION_DOMAIN_UPDATE","ORGANIZATION_DOMAIN_VERIFY","ORGANIZATION_DOMAIN_REMOVE","JIRA_INTEGRATION_GET","JIRA_INTEGRATION_UPSERT","JIRA_INTEGRATION_DELETE","JIRA_BOARDS_LIST","JIRA_BOARD_COLUMNS_LIST","JIRA_AUTOMATION_LIST","JIRA_AUTOMATION_UPSERT","JIRA_RUN_START"]},{id:"members:manage",label:"Manage members",description:"Invite members, remove them, and change their roles",section:"Organization",tools:["ORGANIZATION_MEMBER_LIST","ORGANIZATION_MEMBER_ADD","ORGANIZATION_MEMBER_REMOVE","ORGANIZATION_MEMBER_UPDATE_ROLE","ORGANIZATION_BILLING_CHECKOUT_START","ORGANIZATION_BILLING_GET","ORGANIZATION_BILLING_PORTAL","INFRA_BILLING_SITES_LIST","INFRA_BILLING_GET","INFRA_BILLING_PORTAL","ORGANIZATION_JOIN_REQUEST_LIST","ORGANIZATION_JOIN_REQUEST_APPROVE","ORGANIZATION_JOIN_REQUEST_DENY"],dangerous:!0},{id:"connections:manage",label:"Manage connections",description:"Create, update, and delete connections",section:"Connections & Agents",tools:["COLLECTION_CONNECTIONS_CREATE","COLLECTION_CONNECTIONS_UPDATE","COLLECTION_CONNECTIONS_DELETE","REPORTS_SETUP","REPORTS_RUN","REPORTS_BIND","REPORTS_CONNECTION_STATUS","REPORTS_SET_REPOSITORY"],dangerous:!0},{id:"agents:manage",label:"Manage agents",description:"Create, configure, and delete agents",section:"Connections & Agents",tools:["COLLECTION_VIRTUAL_MCP_CREATE","COLLECTION_VIRTUAL_MCP_UPDATE","COLLECTION_VIRTUAL_MCP_DELETE","VIRTUAL_MCP_PINNED_VIEWS_UPDATE","PROJECT_FOLDERS_SET"],dangerous:!0},{id:"automations:manage",label:"Manage automations",description:"Create, update, run, and delete automations",section:"Automations",tools:["AUTOMATION_CREATE","AUTOMATION_UPDATE","AUTOMATION_DELETE","AUTOMATION_TRIGGER_ADD","AUTOMATION_TRIGGER_REMOVE","AUTOMATION_TRIGGER_ROTATE_TOKEN","AUTOMATION_RUN"],dangerous:!0},{id:"monitoring:view",label:"View monitoring",description:"Access logs and usage statistics",section:"Monitoring",tools:["MONITORING_HEATMAP","MONITORING_LOG_GET","MONITORING_LOGS_LIST","MONITORING_STATS","MONITORING_THREAD_USAGE"]},{id:"secrets:manage",label:"Manage secrets",description:"Create and list secrets stored in the credential vault",section:"Organization",tools:["SECRET_CREATE","SECRET_LIST"]},{id:"assets:manage",label:"Manage assets",description:"Upload and delete files in configured buckets",section:"Organization",tools:["FILE_OBJECT_UPLOAD","FILE_OBJECT_DELETE"]},{id:"repositories:connect",label:"Connect repositories",description:"Connect git provider accounts and link existing repositories",section:"Organization",tools:["GIT_ACCOUNT_CONNECT_TOKEN","REPOSITORY_LINK"]},{id:"file-configs:manage",label:"Manage file configs",description:"Create, list, update and delete S3 bucket configurations and synced GitHub repositories",section:"Organization",tools:["FILE_CONFIG_CREATE","FILE_CONFIG_LIST","FILE_CONFIG_UPDATE","FILE_CONFIG_DELETE","FILE_OBJECTS_LIST","FILE_OBJECT_DELETE","FILE_OBJECT_UPLOAD","ORG_REPO_SYNC_CREATE","ORG_REPO_SYNC_LIST","ORG_REPO_SYNC_UPDATE","ORG_REPO_SYNC_DELETE","ORG_REPO_SYNC_RUN"]},{id:"ai-providers:manage",label:"Manage AI providers",description:"Add or remove API keys and provision provider credentials",section:"AI Providers",tools:["AI_PROVIDER_KEY_CREATE","AI_PROVIDER_KEY_LIST","AI_PROVIDER_KEY_DELETE","AI_PROVIDER_KEY_UPDATE","AI_PROVIDER_KEY_PREVIEW","AI_PROVIDER_OAUTH_URL","AI_PROVIDER_OAUTH_EXCHANGE","AI_PROVIDER_PROVISION_KEY","AI_PROVIDER_TOPUP_URL","AI_PROVIDER_CREDITS","AI_PLAN_ENTITLEMENTS","AI_PLAN_LIST","AI_PLAN_SET","AI_PLAN_INVOICE_UPGRADE","CLAUDE_SUBSCRIPTION_CONNECT","CLAUDE_SUBSCRIPTION_STATUS","CLAUDE_SUBSCRIPTION_DISCONNECT","GITHUB_COPILOT_CONNECT","GITHUB_COPILOT_STATUS","GITHUB_COPILOT_DISCONNECT","GITHUB_COPILOT_SHARE"]},{id:"tags:manage",label:"Manage tags",description:"Create, assign, and delete organization tags",section:"Organization",tools:["TAGS_LIST","TAGS_CREATE","TAGS_DELETE","MEMBER_TAGS_GET","MEMBER_TAGS_SET"]},{id:"experiments:manage",label:"Manage experiments",description:"Create, update, and delete A/B experiments, and view results",section:"Experiments",tools:["EXPERIMENT_LIST","EXPERIMENT_GET","EXPERIMENT_CREATE","EXPERIMENT_SUGGEST","EXPERIMENT_IMPLEMENT","EXPERIMENT_IMPLEMENT_LOCAL","EXPERIMENT_PREVIEW_SYNC_LOCAL","EXPERIMENT_UPDATE","EXPERIMENT_DELETE","EXPERIMENT_RESULTS"],dangerous:!0},{id:"registry:manage",label:"Browse registry",description:"Browse the Deco MCP catalog",section:"Store & Registry",tools:["COLLECTION_REGISTRY_APP_LIST","COLLECTION_REGISTRY_APP_GET","COLLECTION_REGISTRY_APP_VERSIONS","COLLECTION_REGISTRY_APP_FILTERS","REGISTRY_ITEM_LIST","REGISTRY_ITEM_SEARCH","REGISTRY_ITEM_GET","REGISTRY_ITEM_VERSIONS","REGISTRY_ITEM_FILTERS"]},{id:"api-keys:manage",label:"Manage API keys",description:"Create, update, and revoke API keys",section:"Developer",tools:["API_KEY_CREATE","API_KEY_LIST","API_KEY_UPDATE","API_KEY_DELETE"]},{id:"storage:delete",label:"Delete from storage",description:"Permanently delete files from object storage",section:"Developer",tools:["DELETE_OBJECT","DELETE_OBJECTS"],dangerous:!0},{id:"lake:read",label:"Query the data lake",description:"Run read-only SQL over the organization's own data lake (orders from connected stores)",section:"Developer",tools:["CUSTOMER_LAKE_QUERY"]}];[...We.find(t=>t.id===Je)?.tools??[]];const fs=["agents:manage","connections:manage","assets:manage","repositories:connect"];new Set(We.filter(t=>fs.includes(t.id)).flatMap(t=>t.tools));function gs(){if(ke)return ke;const t=new Map;for(const e of We){if(e.id===Je)continue;const l=t.get(e.section)??[];l.push(e),t.set(e.section,l)}return ke=Array.from(t.entries()).map(([e,l])=>({section:e,capabilities:l})),ke}function _s(t,e,l){if(l)return!0;const i=new Set(e);return t.tools.every(r=>i.has(r))}function Es(t,e,l){const i=new Set(e);for(const r of t.tools)l?i.add(r):i.delete(r);return Array.from(i)}let ke=null;const Ts=qe({role:qe({id:W().optional(),slug:W().optional(),label:W()}),allowAllStaticPermissions:Ge(),staticPermissions:ae(W()),toolSet:Xe(W(),ae(W())),allowAllModels:Ge(),modelSet:Xe(W(),ae(W())),allowAllProjects:Ge(),projectSet:ae(W()),projectExceptions:ae(W()),allowAllConnections:Ge(),connectionExceptions:ae(W()),memberIds:ae(W())});function ze(t,e,l,i){const r=s.jsx(ce,{checked:e,disabled:l,onCheckedChange:i});return l?s.jsx(be,{children:s.jsxs(je,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:r})}),s.jsx(De,{children:s.jsx("p",{children:t("settings.orgRoleDetail.builtinRolePermissionsCannotBeChanged")})})]})}):r}function As(t){const e=Y.c(41),{allowAllStaticPermissions:l,staticPermissions:i,onAllowAllChange:r,onPermissionsChange:n,readOnly:a,searchQuery:f}=t,_=a===void 0?!1:a,d=ee();let u;e[0]!==f?(u=f.trim().toLowerCase(),e[0]=f,e[1]=u):u=e[1];const m=F.useDeferredValue(u);let T;if(e[2]!==l||e[3]!==m||e[4]!==r||e[5]!==n||e[6]!==_||e[7]!==f||e[8]!==i||e[9]!==d){const E=gs(),c=(A,p)=>{if(!_){if(l&&p){const D=E.flatMap(Rs).flatMap(hs);r(!1),n(D.filter(o=>!A.tools.includes(o)));return}l||n(Es(A,i,!p))}};let g;e[11]!==m?(g=A=>{const{section:p,capabilities:D}=A;return{section:p,capabilities:D.filter(o=>!m||o.label.toLowerCase().includes(m)||o.description.toLowerCase().includes(m))}},e[11]=m,e[12]=g):g=e[12];const S=E.map(g).filter(Is);let C;e[13]!==d?(C=d("settings.orgRoleDetail.general"),e[13]=d,e[14]=C):C=e[14];let h;e[15]!==d?(h=d("settings.orgRoleDetail.allOrgPermissions"),e[15]=d,e[16]=h):h=e[16];let N;e[17]!==d?(N=d("settings.orgRoleDetail.grantFullAccessToAllFeaturesBelow"),e[17]=d,e[18]=N):N=e[18];let x;e[19]!==l||e[20]!==r||e[21]!==n?(x=()=>{r(!l),n([])},e[19]=l,e[20]=r,e[21]=n,e[22]=x):x=e[22];let b;e[23]!==l||e[24]!==_||e[25]!==d||e[26]!==x?(b=ze(d,l,_,x),e[23]=l,e[24]=_,e[25]=d,e[26]=x,e[27]=b):b=e[27];let R;e[28]!==l||e[29]!==r||e[30]!==n||e[31]!==_?(R=_?void 0:()=>{r(!l),n([])},e[28]=l,e[29]=r,e[30]=n,e[31]=_,e[32]=R):R=e[32];let O;e[33]!==R||e[34]!==h||e[35]!==N||e[36]!==b?(O=s.jsx(tt,{children:s.jsx(st,{title:h,description:N,action:b,onClick:R})}),e[33]=R,e[34]=h,e[35]=N,e[36]=b,e[37]=O):O=e[37];let j;e[38]!==O||e[39]!==C?(j=s.jsx(et,{title:C,children:O}),e[38]=O,e[39]=C,e[40]=j):j=e[40],T=s.jsx("div",{children:s.jsxs("div",{className:"flex flex-col gap-10 py-4",children:[j,S.length===0&&m?s.jsx("p",{className:"text-sm text-muted-foreground py-4",children:d("settings.orgRoleDetail.noPermissionsMatch",{searchQuery:f})}):S.map(A=>{const{section:p,capabilities:D}=A;return s.jsx(et,{title:p,children:s.jsx(tt,{children:D.map(o=>{const I=_s(o,i,l);return s.jsx(st,{title:s.jsxs("span",{className:"flex items-center gap-1.5",children:[o.label,o.dangerous&&s.jsx(yt,{size:12,className:"text-warning shrink-0"})]}),description:o.description,action:ze(d,I,_,()=>c(o,I)),onClick:_?void 0:()=>c(o,I)},o.id)})})},p)})]})}),e[2]=l,e[3]=m,e[4]=r,e[5]=n,e[6]=_,e[7]=f,e[8]=i,e[9]=d,e[10]=T}else T=e[10];return T}function Is(t){return t.capabilities.length>0}function hs(t){return t.tools}function Rs(t){return t.capabilities}const Ct={anthropic:"Anthropic",openrouter:"OpenRouter"},ps={openai:"OpenAI",anthropic:"Anthropic",google:"Google","meta-llama":"Meta",mistralai:"Mistral","x-ai":"xAI",deepseek:"DeepSeek",qwen:"Qwen",moonshotai:"MoonshotAI",nvidia:"NVIDIA",perplexity:"Perplexity",cohere:"Cohere",amazon:"Amazon",microsoft:"Microsoft","z-ai":"Z.ai","ibm-granite":"IBM Granite",alibaba:"Alibaba",baidu:"Baidu",bytedance:"ByteDance",tencent:"Tencent",minimax:"MiniMax",nousresearch:"Nous Research",allenai:"Allen AI",inception:"Inception"};function xs(t,e){const l=t.indexOf("/"),i=l>0?t.slice(0,l):e;return i.startsWith("~")?i.slice(1):i}function Ss(t){return ps[t]??Ct[t]??t}function Os(t){const e=t.indexOf(": ");return e>0&&e<32?t.slice(e+2):t}const Nt=30;function Cs(t){const e=Y.c(40),{connectionId:l,subProviderId:i,subProviderName:r,groupLogo:n,models:a,allConnectionModelIds:f,selectedModels:_,allowAllModels:d,allConnectionModelsSelected:u,onToggleModel:m,onExitAllowAll:T,readOnly:E,defaultExpanded:c}=t,g=ee(),[S,C]=F.useState(c),h=c||S,N=C,[x,b]=F.useState(Nt);let R;e[0]!==u||e[1]!==d||e[2]!==_?(R=A=>d||u||_.includes("*")||_.includes(A),e[0]=u,e[1]=d,e[2]=_,e[3]=R):R=e[3];const O=R;let j;if(e[4]!==f||e[5]!==d||e[6]!==l||e[7]!==h||e[8]!==n||e[9]!==O||e[10]!==a||e[11]!==T||e[12]!==m||e[13]!==E||e[14]!==i||e[15]!==r||e[16]!==g||e[17]!==x){let A;e[19]!==O?(A=B=>O(B.id),e[19]=O,e[20]=A):A=e[20];const p=a.filter(A).length,D=a.slice(0,x),o=a.length>x;let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=()=>N(Ps),e[21]=I):I=e[21];const M=n??pt[i]??xt;let P;e[22]!==r||e[23]!==M?(P=s.jsx(Ot,{icon:M,name:r,size:"sm"}),e[22]=r,e[23]=M,e[24]=P):P=e[24];let L;e[25]!==r?(L=s.jsx("span",{className:"text-sm font-medium truncate",children:r}),e[25]=r,e[26]=L):L=e[26];let y;e[27]!==P||e[28]!==L?(y=s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[P,L]}),e[27]=P,e[28]=L,e[29]=y):y=e[29];const U=g("settings.orgRoleDetail.enabledCount",{enabledCount:p,total:a.length});let G;e[30]!==U?(G=s.jsx(Me,{variant:"muted",children:U}),e[30]=U,e[31]=G):G=e[31];let K;e[32]!==h?(K=h?s.jsx(cs,{size:16,className:"text-muted-foreground shrink-0"}):s.jsx(vt,{size:16,className:"text-muted-foreground shrink-0"}),e[32]=h,e[33]=K):K=e[33];let z;e[34]!==G||e[35]!==K?(z=s.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[G,K]}),e[34]=G,e[35]=K,e[36]=z):z=e[36];let k;e[37]!==z||e[38]!==y?(k=s.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 hover:bg-accent cursor-pointer",onClick:I,children:[y,z]}),e[37]=z,e[38]=y,e[39]=k):k=e[39],j=s.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-card",children:[k,h&&s.jsxs("div",{className:"border-t border-border bg-muted/20",children:[D.map(B=>{const H=O(B.id),$=()=>{if(!E){if(d){T(l,f,B.id);return}m(l,B.id)}};return s.jsxs("div",{className:q("flex items-center justify-between gap-3 px-4 py-3 border-b border-border last:border-b-0",!E&&"hover:bg-accent cursor-pointer"),onClick:$,children:[s.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:s.jsx("span",{className:"text-sm truncate",children:B.title})}),s.jsx("div",{onClick:js,children:E?s.jsx(be,{children:s.jsxs(je,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(ce,{checked:H,disabled:!0,onCheckedChange:bs})})}),s.jsx(De,{children:s.jsx("p",{children:g("settings.orgRoleDetail.builtinRolePermissionsCannotBeChanged")})})]})}):s.jsx(ce,{checked:H,onCheckedChange:$})})]},B.id)}),o&&s.jsx("button",{type:"button",className:"w-full px-4 py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors",onClick:()=>b(Ns),children:g("settings.orgRoleDetail.showMore",{remaining:a.length-x})})]})]}),e[4]=f,e[5]=d,e[6]=l,e[7]=h,e[8]=n,e[9]=O,e[10]=a,e[11]=T,e[12]=m,e[13]=E,e[14]=i,e[15]=r,e[16]=g,e[17]=x,e[18]=j}else j=e[18];return j}function Ns(t){return t+Nt}function bs(){}function js(t){return t.stopPropagation()}function Ps(t){return!t}function Ds(t){const e=Y.c(33),{connection:l,selectedModels:i,allowAllModels:r,onToggleModel:n,onExitAllowAll:a,allConnectionModelsSelected:f,searchQuery:_,readOnly:d}=t,u=ns(l.id);let m,T,E,c,g;if(e[0]!==f||e[1]!==r||e[2]!==l.id||e[3]!==l.label||e[4]!==l.providerId||e[5]!==a||e[6]!==n||e[7]!==u||e[8]!==d||e[9]!==_||e[10]!==i){g=Symbol.for("react.early_return_sentinel");e:{let h;e[16]!==l.label?(h=I=>({...I,id:I.modelId,provider:l.label}),e[16]=l.label,e[17]=h):h=e[17];const N=u.filter(ys).map(h),x=_.trim().toLowerCase(),b=x?N.filter(I=>I.title.toLowerCase().includes(x)||I.id.toLowerCase().includes(x)||I.provider?.toLowerCase().includes(x)):N;if(b.length===0){g=null;break e}const R=new Map;for(const I of b){const M=xs(I.id,l.providerId),P=R.get(M)??{models:[],logo:null};P.models.push({id:I.id,title:Os(I.title),logo:I.logo}),!P.logo&&I.logo&&(P.logo=I.logo),R.set(M,P)}const O=Array.from(R.entries()).map(ws).sort(Ms),j=O.length===1||x.length>0;E="flex flex-col gap-3";const A=pt[l.providerId]??xt;let p;e[18]!==l.providerId||e[19]!==A?(p=s.jsx("img",{src:A,alt:l.providerId,className:"w-4 h-4 rounded-sm dark:bg-white dark:rounded-sm dark:p-px"}),e[18]=l.providerId,e[19]=A,e[20]=p):p=e[20];const D=Ct[l.providerId]??l.providerId;let o;e[21]!==D?(o=s.jsx("h4",{className:"text-sm font-medium",children:D}),e[21]=D,e[22]=o):o=e[22],e[23]!==o||e[24]!==p?(c=s.jsxs("div",{className:"flex items-center gap-2",children:[p,o]}),e[23]=o,e[24]=p,e[25]=c):c=e[25],m="flex flex-col gap-3",T=O.map(I=>s.jsx(Cs,{connectionId:l.id,subProviderId:I.id,subProviderName:I.name,groupLogo:I.logo,models:I.models,allConnectionModelIds:N.map(Ls),selectedModels:i,allowAllModels:r,allConnectionModelsSelected:f,onToggleModel:n,onExitAllowAll:a,readOnly:d,defaultExpanded:j},I.id))}e[0]=f,e[1]=r,e[2]=l.id,e[3]=l.label,e[4]=l.providerId,e[5]=a,e[6]=n,e[7]=u,e[8]=d,e[9]=_,e[10]=i,e[11]=m,e[12]=T,e[13]=E,e[14]=c,e[15]=g}else m=e[11],T=e[12],E=e[13],c=e[14],g=e[15];if(g!==Symbol.for("react.early_return_sentinel"))return g;let S;e[26]!==m||e[27]!==T?(S=s.jsx("div",{className:m,children:T}),e[26]=m,e[27]=T,e[28]=S):S=e[28];let C;return e[29]!==E||e[30]!==c||e[31]!==S?(C=s.jsxs("div",{className:E,children:[c,S]}),e[29]=E,e[30]=c,e[31]=S,e[32]=C):C=e[32],C}function Ls(t){return t.id}function Ms(t,e){return t.name.localeCompare(e.name)}function ws(t){const[e,l]=t;return{id:e,name:Ss(e),logo:l.logo,models:l.models}}function ys(t,e,l){return l.findIndex(i=>i.modelId===t.modelId)===e}function vs(t){const e=Y.c(41),{allowAllModels:l,modelSet:i,onAllowAllChange:r,onModelSetChange:n,readOnly:a,searchQuery:f}=t,_=a===void 0?!1:a,d=ee(),u=F.useDeferredValue(f),m=os();let T;e[0]!==i||e[1]!==n?(T=(A,p)=>{const D=i[A]??[],o={...i};if(D.includes(p)){const I=D.filter(M=>M!==p);I.length===0?delete o[A]:o[A]=I}else o[A]=[...D,p];n(o)},e[0]=i,e[1]=n,e[2]=T):T=e[2];const E=T;let c;e[3]!==i||e[4]!==r||e[5]!==n?(c=(A,p,D)=>{r(!1),n({...i,[A]:p.filter(o=>o!==D)})},e[3]=i,e[4]=r,e[5]=n,e[6]=c):c=e[6];const g=c,S=!_&&"hover:bg-accent cursor-pointer";let C;e[7]!==S?(C=q("flex items-center justify-between px-4 py-3 rounded-lg border border-border bg-card",S),e[7]=S,e[8]=C):C=e[8];let h;e[9]!==l||e[10]!==r||e[11]!==n||e[12]!==_?(h=()=>{if(_)return;const A=!l;r(A),A&&n({})},e[9]=l,e[10]=r,e[11]=n,e[12]=_,e[13]=h):h=e[13];let N;e[14]!==d?(N=d("settings.orgRoleDetail.allModels"),e[14]=d,e[15]=N):N=e[15];let x;e[16]!==N?(x=s.jsx("span",{className:"text-sm font-medium",children:N}),e[16]=N,e[17]=x):x=e[17];let b;e[18]!==l||e[19]!==r||e[20]!==n||e[21]!==_||e[22]!==d?(b=s.jsx("div",{onClick:ks,children:_?s.jsx(be,{children:s.jsxs(je,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(ce,{checked:l,disabled:!0,onCheckedChange:Gs})})}),s.jsx(De,{children:s.jsx("p",{children:d("settings.orgRoleDetail.builtinRolePermissionsCannotBeChanged")})})]})}):s.jsx(ce,{checked:l,onCheckedChange:A=>{r(A),A&&n({})}})}),e[18]=l,e[19]=r,e[20]=n,e[21]=_,e[22]=d,e[23]=b):b=e[23];let R;e[24]!==C||e[25]!==h||e[26]!==x||e[27]!==b?(R=s.jsxs("div",{className:C,onClick:h,children:[x,b]}),e[24]=C,e[25]=h,e[26]=x,e[27]=b,e[28]=R):R=e[28];let O;e[29]!==m||e[30]!==l||e[31]!==u||e[32]!==g||e[33]!==i||e[34]!==_||e[35]!==d||e[36]!==E?(O=m.length===0?s.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:d("settings.orgRoleDetail.noLlmConnectionsConfigured")}):m.map(A=>s.jsx(F.Suspense,{fallback:s.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(we,{className:"size-4"}),d("settings.orgRoleDetail.loadingModels")]}),children:s.jsx(Ds,{connection:A,selectedModels:i[A.id]??[],allowAllModels:l,onToggleModel:E,onExitAllowAll:g,allConnectionModelsSelected:(i[A.id]??[]).includes("*"),searchQuery:u,readOnly:_})},A.id)),e[29]=m,e[30]=l,e[31]=u,e[32]=g,e[33]=i,e[34]=_,e[35]=d,e[36]=E,e[37]=O):O=e[37];let j;return e[38]!==R||e[39]!==O?(j=s.jsxs("div",{className:"flex flex-col h-full overflow-auto gap-6 pb-6",children:[R,O]}),e[38]=R,e[39]=O,e[40]=j):j=e[40],j}function Gs(){}function ks(t){return t.stopPropagation()}function Bs(t){const e=Y.c(49),{allowAllProjects:l,projectSet:i,projectExceptions:r,onAllowAllChange:n,onProjectSetChange:a,onProjectExceptionsChange:f,readOnly:_,searchQuery:d}=t,u=_===void 0?!1:_,m=ee(),T=F.useDeferredValue(d),E=ls();let c;if(e[0]!==l||e[1]!==T||e[2]!==n||e[3]!==f||e[4]!==a||e[5]!==r||e[6]!==i||e[7]!==u||e[8]!==d||e[9]!==m||e[10]!==E){const g=rs(E),S=T.trim().toLowerCase(),C=S?g.filter(L=>L.title.toLowerCase().includes(S)):g;let h;e[12]!==l||e[13]!==f||e[14]!==a||e[15]!==r||e[16]!==i?(h=L=>{const[y,U]=l?[r,f]:[i,a];U(y.includes(L)?y.filter(G=>G!==L):[...y,L])},e[12]=l,e[13]=f,e[14]=a,e[15]=r,e[16]=i,e[17]=h):h=e[17];const N=h;let x;e[18]!==n||e[19]!==f||e[20]!==a?(x=L=>{n(L),a([]),f([])},e[18]=n,e[19]=f,e[20]=a,e[21]=x):x=e[21];const b=x,R=!u&&"hover:bg-accent cursor-pointer";let O;e[22]!==R?(O=q("flex items-center justify-between px-4 py-3 rounded-lg border border-border bg-card",R),e[22]=R,e[23]=O):O=e[23];let j;e[24]!==l||e[25]!==u||e[26]!==b?(j=()=>{u||b(!l)},e[24]=l,e[25]=u,e[26]=b,e[27]=j):j=e[27];let A;e[28]!==m?(A=m("settings.orgRoleDetail.allProjects"),e[28]=m,e[29]=A):A=e[29];let p;e[30]!==A?(p=s.jsx("span",{className:"text-sm font-medium",children:A}),e[30]=A,e[31]=p):p=e[31];let D;e[32]!==m?(D=m("settings.orgRoleDetail.allProjectsDescription"),e[32]=m,e[33]=D):D=e[33];let o;e[34]!==D?(o=s.jsx("span",{className:"text-xs text-muted-foreground",children:D}),e[34]=D,e[35]=o):o=e[35];let I;e[36]!==o||e[37]!==p?(I=s.jsxs("div",{className:"flex flex-col gap-0.5",children:[p,o]}),e[36]=o,e[37]=p,e[38]=I):I=e[38];let M;e[39]!==l||e[40]!==u||e[41]!==b||e[42]!==m?(M=s.jsx("div",{onClick:Ks,children:u?s.jsx(be,{children:s.jsxs(je,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(ce,{checked:l,disabled:!0,onCheckedChange:Us})})}),s.jsx(De,{children:s.jsx("p",{children:m("settings.orgRoleDetail.builtinRolePermissionsCannotBeChanged")})})]})}):s.jsx(ce,{checked:l,onCheckedChange:b})}),e[39]=l,e[40]=u,e[41]=b,e[42]=m,e[43]=M):M=e[43];let P;e[44]!==I||e[45]!==M||e[46]!==O||e[47]!==j?(P=s.jsxs("div",{className:O,onClick:j,children:[I,M]}),e[44]=I,e[45]=M,e[46]=O,e[47]=j,e[48]=P):P=e[48],c=s.jsxs("div",{className:"flex flex-col h-full overflow-auto gap-6 p-4",children:[P,g.length===0?s.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:m("settings.orgRoleDetail.noProjectsAvailable")}):C.length===0?s.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:m("settings.orgRoleDetail.noProjectsMatch",{searchQuery:d})}):s.jsx("div",{className:"flex flex-col gap-1",children:C.map(L=>{const y=l?!r.includes(L.id):i.includes(L.id);return s.jsxs("label",{className:q("flex items-center gap-3 px-3 py-2 rounded-lg border border-transparent",u?"cursor-default":"hover:bg-accent cursor-pointer"),children:[s.jsx(Ze,{checked:y,disabled:u,onCheckedChange:()=>{u||N(L.id)}}),s.jsx(is,{icon:L.icon,name:L.title}),s.jsx("span",{className:"text-sm truncate",children:L.title})]},L.id)})})]}),e[0]=l,e[1]=T,e[2]=n,e[3]=f,e[4]=a,e[5]=r,e[6]=i,e[7]=u,e[8]=d,e[9]=m,e[10]=E,e[11]=c}else c=e[11];return c}function Us(){}function Ks(t){return t.stopPropagation()}function Vs(t){const e=Y.c(48),{allowAllConnections:l,connectionExceptions:i,onAllowAllChange:r,onConnectionExceptionsChange:n,readOnly:a,searchQuery:f,children:_}=t,d=a===void 0?!1:a,u=ee(),m=F.useDeferredValue(f),T=St();let E;if(e[0]!==T||e[1]!==m){const P=m.trim().toLowerCase();E=P?T.filter(L=>L.title.toLowerCase().includes(P)):T,e[0]=T,e[1]=m,e[2]=E}else E=e[2];const c=E;let g;e[3]!==i||e[4]!==n?(g=P=>{n(i.includes(P)?i.filter(L=>L!==P):[...i,P])},e[3]=i,e[4]=n,e[5]=g):g=e[5];const S=g,C=!d&&"hover:bg-accent cursor-pointer";let h;e[6]!==C?(h=q("flex items-center justify-between px-4 py-3 border-b border-border",C),e[6]=C,e[7]=h):h=e[7];let N;e[8]!==l||e[9]!==r||e[10]!==d?(N=()=>{d||r(!l)},e[8]=l,e[9]=r,e[10]=d,e[11]=N):N=e[11];let x;e[12]!==u?(x=u("settings.orgRoleDetail.allConnections"),e[12]=u,e[13]=x):x=e[13];let b;e[14]!==x?(b=s.jsx("span",{className:"text-sm font-medium",children:x}),e[14]=x,e[15]=b):b=e[15];let R;e[16]!==u?(R=u("settings.orgRoleDetail.allConnectionsDescription"),e[16]=u,e[17]=R):R=e[17];let O;e[18]!==R?(O=s.jsx("span",{className:"text-xs text-muted-foreground",children:R}),e[18]=R,e[19]=O):O=e[19];let j;e[20]!==O||e[21]!==b?(j=s.jsxs("div",{className:"flex flex-col gap-0.5",children:[b,O]}),e[20]=O,e[21]=b,e[22]=j):j=e[22];let A;e[23]!==l||e[24]!==r?(A=()=>r(!l),e[23]=l,e[24]=r,e[25]=A):A=e[25];let p;e[26]!==l||e[27]!==d||e[28]!==u||e[29]!==A?(p=ze(u,l,d,A),e[26]=l,e[27]=d,e[28]=u,e[29]=A,e[30]=p):p=e[30];let D;e[31]!==p?(D=s.jsx("div",{onClick:Fs,children:p}),e[31]=p,e[32]=D):D=e[32];let o;e[33]!==j||e[34]!==D||e[35]!==h||e[36]!==N?(o=s.jsxs("div",{className:h,onClick:N,children:[j,D]}),e[33]=j,e[34]=D,e[35]=h,e[36]=N,e[37]=o):o=e[37];let I;e[38]!==l||e[39]!==_||e[40]!==i||e[41]!==c||e[42]!==d||e[43]!==S?(I=l?s.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-4 flex flex-col gap-1",children:c.map(P=>s.jsxs("label",{className:q("flex items-center gap-3 px-3 py-2 rounded-lg border border-transparent",d?"cursor-default":"hover:bg-accent cursor-pointer"),children:[s.jsx(Ze,{checked:!i.includes(P.id),disabled:d,onCheckedChange:()=>{d||S(P.id)}}),s.jsx(Ot,{icon:P.icon,name:P.title,size:"sm"}),s.jsx("span",{className:"text-sm truncate",children:P.title})]},P.id))}):s.jsx("div",{className:"flex-1 min-h-0",children:_}),e[38]=l,e[39]=_,e[40]=i,e[41]=c,e[42]=d,e[43]=S,e[44]=I):I=e[44];let M;return e[45]!==o||e[46]!==I?(M=s.jsxs("div",{className:"flex flex-col h-full",children:[o,I]}),e[45]=o,e[46]=I,e[47]=M):M=e[47],M}function Fs(t){return t.stopPropagation()}function zs(t){const e=Y.c(75),{open:l,onOpenChange:i,selectedMemberIds:r,onAddMembers:n}=t,a=ee(),[f,_]=F.useState(""),d=F.useDeferredValue(f);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];const[m,T]=F.useState(u),{data:E}=ct();let c,g,S,C,h,N,x,b,R,O,j;if(e[1]!==E?.data?.members||e[2]!==d||e[3]!==n||e[4]!==i||e[5]!==l||e[6]!==m||e[7]!==f||e[8]!==r||e[9]!==a){const G=E?.data?.members??[];let K;e[21]!==d?(K=V=>{const Z=d.toLowerCase();return V.user?.name?.toLowerCase().includes(Z)||V.user?.email?.toLowerCase().includes(Z)},e[21]=d,e[22]=K):K=e[22];const z=G.filter(K);let k;e[23]!==n||e[24]!==i||e[25]!==m?(k=()=>{n(m),T([]),i(!1)},e[23]=n,e[24]=i,e[25]=m,e[26]=k):k=e[26],S=k,g=mt,O=l,j=i,c=ut,b="sm:max-w-md p-0";let B;e[27]!==a?(B=a("settings.orgRoleDetail.addMembersToRole"),e[27]=a,e[28]=B):B=e[28];let H;e[29]!==B?(H=s.jsx(ft,{children:B}),e[29]=B,e[30]=H):H=e[30];let $;e[31]!==a?($=a("settings.orgRoleDetail.selectMembersToAddToThisRole"),e[31]=a,e[32]=$):$=e[32];let X;e[33]!==$?(X=s.jsx(gt,{children:$}),e[33]=$,e[34]=X):X=e[34],e[35]!==H||e[36]!==X?(R=s.jsxs(_t,{className:"px-6 pt-6",children:[H,X]}),e[35]=H,e[36]=X,e[37]=R):R=e[37],N="flex flex-col h-80";let te;e[38]!==a?(te=a("settings.orgRoleDetail.searchMembers"),e[38]=a,e[39]=te):te=e[39],e[40]!==f||e[41]!==te?(x=s.jsx("div",{className:"border-b border-border px-4 py-3",children:s.jsx($e,{value:f,onChange:_,placeholder:te,className:"w-full"})}),e[40]=f,e[41]=te,e[42]=x):x=e[42],C="flex-1 overflow-auto",h=z.length===0?s.jsx("div",{className:"flex items-center justify-center h-full px-6",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:a(f?"settings.orgRoleDetail.noMembersFound":"settings.orgRoleDetail.noMembersAvailable")})}):s.jsx("div",{className:"px-6 py-2 space-y-1",children:z.map(V=>{const Z=V.role!=="owner",J=r.includes(V.id),le=m.includes(V.id);return s.jsxs("label",{className:q("flex items-center gap-3 p-2 rounded-lg",!Z||J?"opacity-50 cursor-not-allowed":"cursor-pointer hover:bg-accent"),children:[s.jsx(Ze,{checked:le||J,onCheckedChange:()=>{!Z||J||T(oe=>oe.includes(V.id)?oe.filter(ne=>ne!==V.id):[...oe,V.id])},disabled:!Z||J}),s.jsx(dt,{url:V.user?.image??void 0,fallback:V.user?.name??"?",shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:V.user?.name||a("settings.orgRoleDetail.unknown")}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:V.user?.email})]}),!Z&&s.jsx(Me,{variant:"secondary",className:"shrink-0",children:a("settings.orgRoleDetail.owner")}),J&&Z&&s.jsx(Me,{variant:"outline",className:"shrink-0",children:a("settings.orgRoleDetail.added")})]},V.id)})}),e[1]=E?.data?.members,e[2]=d,e[3]=n,e[4]=i,e[5]=l,e[6]=m,e[7]=f,e[8]=r,e[9]=a,e[10]=c,e[11]=g,e[12]=S,e[13]=C,e[14]=h,e[15]=N,e[16]=x,e[17]=b,e[18]=R,e[19]=O,e[20]=j}else c=e[10],g=e[11],S=e[12],C=e[13],h=e[14],N=e[15],x=e[16],b=e[17],R=e[18],O=e[19],j=e[20];let A;e[43]!==C||e[44]!==h?(A=s.jsx("div",{className:C,children:h}),e[43]=C,e[44]=h,e[45]=A):A=e[45];let p;e[46]!==A||e[47]!==N||e[48]!==x?(p=s.jsxs("div",{className:N,children:[x,A]}),e[46]=A,e[47]=N,e[48]=x,e[49]=p):p=e[49];let D;e[50]!==a?(D=a("settings.orgRoleDetail.cancel"),e[50]=a,e[51]=D):D=e[51];let o;e[52]!==D?(o=s.jsx(Et,{children:D}),e[52]=D,e[53]=o):o=e[53];const I=m.length===0;let M;e[54]!==m.length||e[55]!==a?(M=a("settings.orgRoleDetail.addWithCount",{count:m.length}),e[54]=m.length,e[55]=a,e[56]=M):M=e[56];let P;e[57]!==S||e[58]!==I||e[59]!==M?(P=s.jsx(Tt,{onClick:S,disabled:I,children:M}),e[57]=S,e[58]=I,e[59]=M,e[60]=P):P=e[60];let L;e[61]!==o||e[62]!==P?(L=s.jsxs(At,{className:"px-6 pb-6",children:[o,P]}),e[61]=o,e[62]=P,e[63]=L):L=e[63];let y;e[64]!==c||e[65]!==p||e[66]!==L||e[67]!==b||e[68]!==R?(y=s.jsxs(c,{className:b,children:[R,p,L]}),e[64]=c,e[65]=p,e[66]=L,e[67]=b,e[68]=R,e[69]=y):y=e[69];let U;return e[70]!==g||e[71]!==y||e[72]!==O||e[73]!==j?(U=s.jsx(g,{open:O,onOpenChange:j,children:y}),e[70]=g,e[71]=y,e[72]=O,e[73]=j,e[74]=U):U=e[74],U}function Ys(t){const e=Y.c(33),{memberIds:l,onMemberIdsChange:i,readOnly:r,readOnlyMessage:n,searchQuery:a,addMemberDialogOpen:f,onAddMemberDialogOpenChange:_}=t,d=r===void 0?!1:r,u=n===void 0?void 0:n,m=ee(),T=F.useDeferredValue(a),{data:E}=ct();let c,g,S;if(e[0]!==E?.data?.members||e[1]!==T||e[2]!==l||e[3]!==i||e[4]!==d||e[5]!==u||e[6]!==a||e[7]!==m){const b=E?.data?.members??[];let R;e[11]!==l?(R=o=>l.includes(o.id),e[11]=l,e[12]=R):R=e[12];const O=b.filter(R);let j;e[13]!==T?(j=o=>{const I=T.toLowerCase();return o.user?.name?.toLowerCase().includes(I)||o.user?.email?.toLowerCase().includes(I)},e[13]=T,e[14]=j):j=e[14];const A=O.filter(j);let p;e[15]!==u||e[16]!==m?(p=u??m("settings.orgRoleDetail.ownerMembershipCannotBeChanged"),e[15]=u,e[16]=m,e[17]=p):p=e[17];const D=p;S="flex flex-col h-full",c="flex-1 overflow-auto",g=O.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("div",{className:"text-center",children:[s.jsx("h3",{className:"text-base font-medium mb-1",children:m("settings.orgRoleDetail.noMembers")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:m("settings.orgRoleDetail.addMembersToGrantPermissions")})]})}):A.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:m("settings.orgRoleDetail.noMembersMatch",{searchQuery:a})})}):s.jsx("div",{className:"p-4 space-y-2",children:A.map(o=>s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/30",children:[s.jsx(dt,{url:o.user?.image??void 0,fallback:o.user?.name??"?",shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:o.user?.name||m("settings.orgRoleDetail.unknown")}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:o.user?.email})]}),d?s.jsx(be,{children:s.jsxs(je,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(re,{variant:"ghost",size:"sm",disabled:!0,"aria-label":m("settings.orgRoleDetail.removeMember",{name:o.user?.name||m("settings.orgRoleDetail.unknown")}),children:s.jsx(lt,{size:16})})})}),s.jsx(De,{children:s.jsx("p",{children:D})})]})}):s.jsx(re,{variant:"ghost",size:"sm","aria-label":m("settings.orgRoleDetail.removeMember",{name:o.user?.name||m("settings.orgRoleDetail.unknown")}),onClick:()=>i(l.filter(I=>I!==o.id)),children:s.jsx(lt,{size:16})})]},o.id))}),e[0]=E?.data?.members,e[1]=T,e[2]=l,e[3]=i,e[4]=d,e[5]=u,e[6]=a,e[7]=m,e[8]=c,e[9]=g,e[10]=S}else c=e[8],g=e[9],S=e[10];let C;e[18]!==c||e[19]!==g?(C=s.jsx("div",{className:c,children:g}),e[18]=c,e[19]=g,e[20]=C):C=e[20];let h;e[21]!==l||e[22]!==i?(h=b=>i([...l,...b]),e[21]=l,e[22]=i,e[23]=h):h=e[23];let N;e[24]!==f||e[25]!==l||e[26]!==_||e[27]!==h?(N=s.jsx(zs,{open:f,onOpenChange:_,selectedMemberIds:l,onAddMembers:h}),e[24]=f,e[25]=l,e[26]=_,e[27]=h,e[28]=N):N=e[28];let x;return e[29]!==S||e[30]!==C||e[31]!==N?(x=s.jsxs("div",{className:S,children:[C,N]}),e[29]=S,e[30]=C,e[31]=N,e[32]=x):x=e[32],x}function Hs(t){const e=Y.c(3);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(we,{className:"size-6 text-muted-foreground"})}),e[0]=l):l=e[0];let i;return e[1]!==t?(i=s.jsx(F.Suspense,{fallback:l,children:s.jsx(Ys,{...t})}),e[1]=t,e[2]=i):i=e[2],i}const Qs={owner:[],admin:[],user:[]};function $s(t,e,l,i){const r=t==="owner"||t==="admin";return{role:{id:l?.id,slug:t,label:t.charAt(0).toUpperCase()+t.slice(1)},allowAllStaticPermissions:r,staticPermissions:Qs[t],toolSet:{},allowAllModels:!0,modelSet:{},allowAllProjects:!0,projectSet:[],projectExceptions:[],allowAllConnections:r,connectionExceptions:[],memberIds:e.filter(n=>n.role===t).map(n=>n.id)}}function Zs(t,e,l){const i=t.permission||{},r=i.self||[],n=r.includes("*"),a=n?[]:r.filter(E=>E!=="*"),f={};for(const[E,c]of Object.entries(i))if(!(E==="self"||E==="models"||E===Ke||E===Ve))if(E==="*")for(const g of l)f[g.id]=c.includes("*")?g.tools?.map(S=>S.name)??[]:c;else{const g=l.find(S=>S.id===E);g&&(f[E]=c.includes("*")?g.tools?.map(S=>S.name)??[]:c)}const _=i.models||[],d=_.length===0||_.includes("*:*"),u={};if(!d)for(const E of _){const c=E.indexOf(":");if(c===-1)continue;const g=E.slice(0,c),S=E.slice(c+1);u[g]||(u[g]=[]),u[g].push(S)}const m=Zt(Jt(i)),T=Wt(i[Ve]??[]);return{role:{id:t.id,slug:t.role,label:t.label},allowAllStaticPermissions:n,staticPermissions:a,toolSet:f,allowAllModels:d,modelSet:u,allowAllProjects:m.kind!=="only",projectSet:m.kind==="only"?m.names:[],projectExceptions:m.kind==="except"?m.names:[],allowAllConnections:T.kind!=="only",connectionExceptions:T.kind==="except"?T.names:[],memberIds:e.filter(E=>E.role===t.role).map(E=>E.id)}}function Js(t,e){const l={};t.allowAllStaticPermissions?l.self=["*"]:t.staticPermissions.length>0&&(l.self=t.staticPermissions);for(const[i,r]of Object.entries(t.toolSet))if(r.length>0){const a=e.find(f=>f.id===i)?.tools?.map(f=>f.name)??[];l[i]=a.length>0&&a.every(f=>r.includes(f))?["*"]:r}if(t.allowAllModels)l.models=["*:*"];else{const i=[];for(const[r,n]of Object.entries(t.modelSet))for(const a of n)i.push(`${r}:${a}`);i.length>0&&(l.models=i)}return t.allowAllProjects?t.projectExceptions.length>0&&(l[Ke]=Ht({names:t.projectExceptions})):l[Ke]=t.projectSet,t.allowAllConnections&&(l[Ve]=[Qt,...t.connectionExceptions.map($t)]),l}function Ws(t,e,l){return t.kind==="builtin"?$s(t.role,e,void 0):t.kind==="custom"?Zs(t.role,e,l):{role:{id:void 0,slug:void 0,label:""},allowAllStaticPermissions:!1,staticPermissions:[],toolSet:{},allowAllModels:!0,modelSet:{},allowAllProjects:!0,projectSet:[],projectExceptions:[],allowAllConnections:!1,connectionExceptions:[],memberIds:[]}}function qs(t){const e=Y.c(19),{readOnly:l,readOnlyMessage:i,onOpen:r}=t,n=i===void 0?void 0:i,a=ee();let f;e[0]!==n||e[1]!==a?(f=n??a("settings.orgRoleDetail.ownerMembershipCannotBeChanged"),e[0]=n,e[1]=a,e[2]=f):f=e[2];const _=f;if(l){let T;e[3]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsx(Fe,{size:16}),e[3]=T):T=e[3];let E;e[4]!==a?(E=a("settings.orgRoleDetail.addMember"),e[4]=a,e[5]=E):E=e[5];let c;e[6]!==E?(c=s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsxs(re,{variant:"outline",size:"sm",disabled:!0,children:[T,E]})})}),e[6]=E,e[7]=c):c=e[7];let g;e[8]!==_?(g=s.jsx(De,{children:s.jsx("p",{children:_})}),e[8]=_,e[9]=g):g=e[9];let S;return e[10]!==c||e[11]!==g?(S=s.jsx(be,{children:s.jsxs(je,{children:[c,g]})}),e[10]=c,e[11]=g,e[12]=S):S=e[12],S}let d;e[13]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx(Fe,{size:16}),e[13]=d):d=e[13];let u;e[14]!==a?(u=a("settings.orgRoleDetail.addMember"),e[14]=a,e[15]=u):u=e[15];let m;return e[16]!==r||e[17]!==u?(m=s.jsxs(re,{variant:"outline",size:"sm",onClick:r,children:[d,u]}),e[16]=r,e[17]=u,e[18]=m):m=e[18],m}function Xs(t){const e=Y.c(14),{locator:l}=Ye(),i=He(),r=St();let n;e[0]!==l?(n=Ne.members(l),e[0]=l,e[1]=n):n=e[1];let a;e[2]!==i?(a=()=>i.organization.listMembers(),e[2]=i,e[3]=a):a=e[3];let f;e[4]!==n||e[5]!==a?(f={queryKey:n,queryFn:a},e[4]=n,e[5]=a,e[6]=f):f=e[6];const{data:_,isPending:d}=nt(f);if(d||!r){let E;return e[7]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(se,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(we,{className:"size-8 text-muted-foreground"})})}),e[7]=E):E=e[7],E}let u;e[8]!==_?.data?.members?(u=_?.data?.members??[],e[8]=_?.data?.members,e[9]=u):u=e[9];const m=u;let T;return e[10]!==r||e[11]!==m||e[12]!==t?(T=s.jsx(el,{...t,members:m,connections:r}),e[10]=r,e[11]=m,e[12]=t,e[13]=T):T=e[13],T}function el({target:t,onBack:e,onSaved:l,members:i,connections:r}){const n=ee(),{locator:a}=Ye(),f=He(),_=it(),d=t.kind==="builtin",u=t.kind==="builtin"&&t.role==="owner",m=t.kind==="new",[T,E]=F.useState(d?"org":"mcp"),c=Pt({resolver:Dt(Ts),defaultValues:Ws(t,i,r)}),g=c.formState.isValid,S=c.formState.isDirty,C=rt({mutationFn:async o=>{const I=Js(o,r),M=o.role.slug||o.role.label.toLowerCase().replace(/\s+/g,"-"),P=(o.role.slug==="owner"||o.role.slug==="admin"||o.role.slug==="user")&&!o.role.id,L=async(y,U)=>{const G=i.filter(k=>k.role===(U??y)).map(k=>k.id),K=o.memberIds.filter(k=>!G.includes(k)),z=G.filter(k=>!o.memberIds.includes(k));for(const k of K){const B=await f.organization.updateMemberRole({memberId:k,role:[y]});if(B?.error)throw new Error(B.error.message??n("settings.orgRoleDetail.somethingWentWrong"))}for(const k of z){const B=await f.organization.updateMemberRole({memberId:k,role:["user"]});if(B?.error)throw new Error(B.error.message??n("settings.orgRoleDetail.somethingWentWrong"))}};if(P)return await L(o.role.slug),o;if(o.role.id){const y=o.role.label.toLowerCase().replace(/\s+/g,"-"),U=o.role.slug,G=y!==U,K=await f.organization.updateRole({roleId:o.role.id,data:{permission:I,...G?{roleName:y}:{}}});if(K?.error)throw new Error(K.error.message??n("settings.orgRoleDetail.somethingWentWrong"));return await L(G?y:U,G?U:void 0),G?{...o,role:{...o.role,slug:y}}:o}else{const y=await f.organization.createRole({role:M,permission:I});if(y?.error)throw new Error(y.error.message??n("settings.orgRoleDetail.somethingWentWrong"));for(const U of o.memberIds){const G=await f.organization.updateMemberRole({memberId:U,role:[M]});if(G?.error)throw new Error(G.error.message)}return{...o,role:{...o.role,id:y.data?.roleData?.id,slug:M}}}},onSuccess:(o,I)=>{_.invalidateQueries({queryKey:Ne.members(a)}),_.invalidateQueries({queryKey:Ne.organizationRoles(a)});const M=!I.role.id&&!I.role.slug,P=I.role.slug==="owner"&&!I.role.id;Qe(P?"role_members_updated":M?"role_created":"role_updated",{role_slug:I.role.slug??null}),Le.success(n(P?"settings.orgRoleDetail.membersUpdatedSuccessfully":M?"settings.orgRoleDetail.roleCreatedSuccessfully":"settings.orgRoleDetail.roleUpdatedSuccessfully")),c.reset(o),l(o.role.id)},onError:o=>{Le.error(o instanceof Error?o.message:n("settings.orgRoleDetail.failedToSaveRole"))}}),h=c.handleSubmit(o=>{if(!o.role.label.trim()){Le.error(n("settings.orgRoleDetail.roleNameIsRequired")),c.setFocus("role.label");return}C.mutate(o)}),N=!u,x=t.kind==="builtin"?t.role.charAt(0).toUpperCase()+t.role.slice(1):t.kind==="custom"?t.role.label:"",b=[...u?[]:[{id:"mcp",label:n("settings.orgRoleDetail.mcpPermissions"),icon:ds}],{id:"org",label:n("settings.orgRoleDetail.organizationPermissions"),icon:as},{id:"models",label:n("settings.orgRoleDetail.models"),icon:Lt},{id:"projects",label:n("settings.orgRoleDetail.projects"),icon:ms},{id:"members",label:n("settings.orgRoleDetail.members"),icon:Mt}],[R,O]=F.useState(""),[j,A]=F.useState(!1),p=o=>{E(o),O("")},D={mcp:n("settings.orgRoleDetail.searchMcpServers"),org:n("settings.orgRoleDetail.searchPermissions"),models:n("settings.orgRoleDetail.searchModels"),projects:n("settings.orgRoleDetail.searchProjects"),members:n("settings.orgRoleDetail.searchMembers")};return s.jsx(se,{children:s.jsxs(se.Content,{className:q("flex flex-col",T!=="org"&&"overflow-hidden"),children:[s.jsx("div",{className:"shrink-0 mx-auto w-full max-w-[1200px] px-4 md:px-10 pt-8 md:pt-12 pb-4",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsx(se.Title,{actions:N&&s.jsxs(s.Fragment,{children:[s.jsx(re,{variant:"outline",size:"sm",onClick:e,disabled:C.isPending,children:n("settings.orgRoleDetail.cancel")}),s.jsx(re,{size:"sm",onClick:h,disabled:C.isPending||!g||!S,children:C.isPending?n("settings.orgRoleDetail.saving"):n(m?"settings.orgRoleDetail.createRole":"settings.orgRoleDetail.saveChanges")})]}),children:s.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[s.jsx("div",{className:q("size-2.5 rounded-full shrink-0",t.kind==="builtin"?Rt(t.role,!0):Yt(c.watch("role.label")))}),u&&s.jsx(at,{size:16,className:"text-muted-foreground shrink-0"}),m||t.kind==="custom"?s.jsx("input",{...c.register("role.label"),placeholder:n("settings.orgRoleDetail.roleName"),className:"leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-64 placeholder:text-muted-foreground/50",autoFocus:m}):s.jsx("span",{className:"truncate",children:x})]})}),s.jsx(s.Fragment,{children:s.jsx(wt.Toolbar.Left.Portal,{children:s.jsx(se.Tabs,{children:b.map(o=>s.jsx(se.Tab,{active:T===o.id,onClick:()=>p(o.id),children:o.label},o.id))})})}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx($e,{value:R,onChange:O,placeholder:D[T]??"Search...",className:"w-full md:w-[375px]"}),T==="members"&&s.jsx(qs,{readOnly:t.kind==="builtin"&&t.role==="owner",onOpen:()=>A(!0)})]})]})}),s.jsx("div",{className:q("mx-auto w-full max-w-[1200px] px-4 md:px-10 pb-6",T!=="org"&&"flex-1 min-h-0"),children:s.jsxs("div",{className:q(T!=="org"&&"h-full overflow-hidden",T!=="models"&&T!=="projects"&&T!=="org"&&"border border-border rounded-xl bg-card"),children:[T==="mcp"&&!u&&s.jsx(F.Suspense,{fallback:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(we,{className:"size-6 text-muted-foreground"})}),children:s.jsx(Vs,{allowAllConnections:c.watch("allowAllConnections"),connectionExceptions:c.watch("connectionExceptions"),onAllowAllChange:o=>{c.setValue("allowAllConnections",o,{shouldDirty:!0}),c.setValue("connectionExceptions",[],{shouldDirty:!0})},onConnectionExceptionsChange:o=>c.setValue("connectionExceptions",o,{shouldDirty:!0}),readOnly:t.kind==="builtin",searchQuery:R,children:s.jsx(ss,{toolSet:c.watch("toolSet"),onToolSetChange:o=>c.setValue("toolSet",o,{shouldDirty:!0}),searchQuery:R})})}),T==="org"&&s.jsx(As,{allowAllStaticPermissions:c.watch("allowAllStaticPermissions"),staticPermissions:c.watch("staticPermissions"),onAllowAllChange:o=>c.setValue("allowAllStaticPermissions",o,{shouldDirty:!0}),onPermissionsChange:o=>c.setValue("staticPermissions",o,{shouldDirty:!0}),readOnly:u,searchQuery:R}),T==="models"&&s.jsx(vs,{allowAllModels:c.watch("allowAllModels"),modelSet:c.watch("modelSet"),onAllowAllChange:o=>c.setValue("allowAllModels",o,{shouldDirty:!0}),onModelSetChange:o=>c.setValue("modelSet",o,{shouldDirty:!0}),readOnly:u,searchQuery:R}),T==="projects"&&s.jsx(Bs,{allowAllProjects:c.watch("allowAllProjects"),projectSet:c.watch("projectSet"),projectExceptions:c.watch("projectExceptions"),onAllowAllChange:o=>c.setValue("allowAllProjects",o,{shouldDirty:!0}),onProjectSetChange:o=>c.setValue("projectSet",o,{shouldDirty:!0}),onProjectExceptionsChange:o=>c.setValue("projectExceptions",o,{shouldDirty:!0}),readOnly:u,searchQuery:R}),T==="members"&&s.jsx(Hs,{memberIds:c.watch("memberIds"),onMemberIdsChange:o=>c.setValue("memberIds",o,{shouldDirty:!0}),readOnly:t.kind==="builtin"&&(t.role==="owner"||t.role==="user"),readOnlyMessage:t.kind==="builtin"&&t.role==="user"?n("settings.orgRoleDetail.userIsDefaultRoleMessage"):n("settings.orgRoleDetail.ownerMembershipCannotBeChanged"),searchQuery:R,addMemberDialogOpen:j,onAddMemberDialogOpenChange:A})]})})]})})}function tl(t){return t.kind==="builtin"?`builtin-${t.role}`:t.kind==="custom"?`custom-${t.role.id}`:"new"}function sl(t){const e=Y.c(6),{area:l,children:i}=t,{isPrivileged:r,loading:n,error:a}=Gt();let f;return e[0]!==l||e[1]!==i||e[2]!==a||e[3]!==r||e[4]!==n?(f=s.jsx(us,{granted:r,loading:n,error:a,area:l,children:i}),e[0]=l,e[1]=i,e[2]=a,e[3]=r,e[4]=n,e[5]=f):f=e[5],f}const ll=[{role:"owner",labelKey:"settings.roles.roleOwner"},{role:"admin",labelKey:"settings.roles.roleAdmin"},{role:"user",labelKey:"settings.roles.roleUser"}];function ol(){const t=Y.c(128),e=ee(),[l,i]=F.useState(""),[r,n]=F.useState(null),a=Ut();let f;t[0]===Symbol.for("react.memo_cache_sentinel")?(f={strict:!1},t[0]=f):f=t[0];const{role:_}=It(f),{locator:d}=Ye(),u=He(),m=it(),{customRoles:T,refetch:E}=qt();let c;t[1]!==a?(c=w=>a({to:".",search:v=>({...v,role:w})}),t[1]=a,t[2]=c):c=t[2];const g=c;let S;e:{if(!_){S=null;break e}if(_==="new"){S={kind:"new"};break e}if(_.startsWith("builtin-")){S={kind:"builtin",role:_.slice(8)};break e}let w;t[3]!==_?(w=Q=>Q.id===_,t[3]=_,t[4]=w):w=t[4];const v=T.find(w);S=v?{kind:"custom",role:v}:null}const C=S;let h;t[5]!==d?(h=Ne.members(d),t[5]=d,t[6]=h):h=t[6];let N;t[7]!==u?(N=()=>u.organization.listMembers(),t[7]=u,t[8]=N):N=t[8];let x;t[9]!==h||t[10]!==N?(x={queryKey:h,queryFn:N},t[9]=h,t[10]=N,t[11]=x):x=t[11];const{data:b}=nt(x);let R;t[12]!==b?.data?.members?(R=b?.data?.members??[],t[12]=b?.data?.members,t[13]=R):R=t[13];const O=R;let j;t[14]!==O?(j=w=>O.filter(v=>v.role===w).length,t[14]=O,t[15]=j):j=t[15];const A=j;let p;if(t[16]!==T||t[17]!==A||t[18]!==l||t[19]!==e){let w;t[21]!==A||t[22]!==e?(w=ie=>({kind:"builtin",role:{...ie,memberCount:A(ie.role),label:e(ie.labelKey)}}),t[21]=A,t[22]=e,t[23]=w):w=t[23];const v=ll.map(w);let Q;t[24]!==A?(Q=ie=>({kind:"custom",role:{...ie,memberCount:A(ie.role)}}),t[24]=A,t[25]=Q):Q=t[25];const bt=T.map(Q);if(p=[...v,...bt],l){const ie=l.toLowerCase();p=p.filter(jt=>jt.role.label.toLowerCase().includes(ie))}t[16]=T,t[17]=A,t[18]=l,t[19]=e,t[20]=p}else p=t[20];let D;t[26]!==u?(D=async w=>{const v=await u.organization.deleteRole({roleId:w});if(v?.error)throw new Error(v.error.message);return v?.data},t[26]=u,t[27]=D):D=t[27];const o=rt({mutationFn:D,onSuccess:(w,v)=>{Qe("role_deleted",{role_id:v}),m.invalidateQueries({queryKey:Ne.members(d)}),m.invalidateQueries({queryKey:Ne.organizationRoles(d)}),Le.success(e("settings.roles.deletedSuccessfully")),E(),C?.kind==="custom"&&C.role.id===v&&g(void 0)},onError:cl});let I;t[28]!==e?(I=e("settings.roles.columnRole"),t[28]=e,t[29]=I):I=t[29];let M;t[30]!==I?(M={id:"role",header:I,render:al,cellClassName:"flex-1 min-w-0",sortable:!0},t[30]=I,t[31]=M):M=t[31];let P;t[32]!==e?(P=e("settings.roles.columnType"),t[32]=e,t[33]=P):P=t[33];let L;t[34]!==e?(L=w=>w.kind==="builtin"?s.jsx(Me,{variant:"secondary",children:e("settings.roles.builtIn")}):s.jsx(Me,{variant:"outline",children:e("settings.roles.custom")}),t[34]=e,t[35]=L):L=t[35];let y;t[36]!==P||t[37]!==L?(y={id:"type",header:P,render:L,cellClassName:"w-28 shrink-0"},t[36]=P,t[37]=L,t[38]=y):y=t[38];let U;t[39]!==e?(U=e("settings.roles.columnPermissions"),t[39]=e,t[40]=U):U=t[40];let G;t[41]!==e?(G=w=>{if(w.kind==="builtin")return w.role.role==="owner"||w.role.role==="admin"?s.jsx("span",{className:"text-sm text-muted-foreground",children:e("settings.roles.fullAccess")}):s.jsx("span",{className:"text-sm text-muted-foreground",children:e("settings.roles.basicAccess")});const v=w.role,Q=[];return v.allowsAllStaticPermissions?Q.push(e("settings.roles.fullOrgAccess")):v.staticPermissionCount&&v.staticPermissionCount>0&&Q.push(e("settings.roles.orgPermsCount",{count:v.staticPermissionCount})),v.allowsAllConnections?Q.push(e("settings.roles.allConnections")):v.connectionCount&&v.connectionCount>0&&Q.push(e("settings.roles.connectionCount",{count:v.connectionCount})),s.jsx("span",{className:"text-sm text-muted-foreground truncate",children:Q.length>0?Q.join(", "):e("settings.roles.noPermissions")})},t[41]=e,t[42]=G):G=t[42];let K;t[43]!==U||t[44]!==G?(K={id:"permissions",header:U,render:G,cellClassName:"flex-1 min-w-0"},t[43]=U,t[44]=G,t[45]=K):K=t[45];let z;t[46]!==e?(z=e("settings.roles.columnMembers"),t[46]=e,t[47]=z):z=t[47];let k;t[48]!==z?(k={id:"members",header:z,render:rl,cellClassName:"w-24 shrink-0"},t[48]=z,t[49]=k):k=t[49];let B;t[50]!==e?(B={id:"actions",header:"",render:w=>w.kind==="builtin"?null:s.jsxs(Kt,{children:[s.jsx(Vt,{asChild:!0,children:s.jsx(re,{variant:"ghost",size:"icon",onClick:il,children:s.jsx(Xt,{size:16})})}),s.jsx(Ft,{align:"end",onClick:nl,children:s.jsxs(zt,{variant:"destructive",onClick:()=>{const v=w.role;v.id&&n({id:v.id,label:v.label})},children:[s.jsx(es,{size:16}),e("settings.roles.delete")]})})]}),cellClassName:"w-12 shrink-0"},t[50]=e,t[51]=B):B=t[51];let H;t[52]!==M||t[53]!==y||t[54]!==K||t[55]!==k||t[56]!==B?(H=[M,y,K,k,B],t[52]=M,t[53]=y,t[54]=K,t[55]=k,t[56]=B,t[57]=H):H=t[57];const $=H;let X;t[58]!==g?(X=w=>{if(w.kind==="builtin")g(`builtin-${w.role.role}`);else{const v=w.role;g(v.id)}},t[58]=g,t[59]=X):X=t[59];const te=X;if(C){let w;t[60]!==g?(w=()=>g(void 0),t[60]=g,t[61]=w):w=t[61];let v;return t[62]!==E||t[63]!==g?(v=()=>{E(),g(void 0)},t[62]=E,t[63]=g,t[64]=v):v=t[64],s.jsx(Xs,{target:C,onBack:w,onSaved:v},tl(C))}let V;t[65]!==e?(V=e("settings.roles.searchPlaceholder"),t[65]=e,t[66]=V):V=t[66];let Z;t[67]===Symbol.for("react.memo_cache_sentinel")?(Z=w=>{w.key==="Escape"&&(i(""),w.target.blur())},t[67]=Z):Z=t[67];let J;t[68]!==l||t[69]!==V?(J=s.jsx($e,{value:l,onChange:i,placeholder:V,className:"w-full md:w-[375px]",onKeyDown:Z}),t[68]=l,t[69]=V,t[70]=J):J=t[70];let le;t[71]!==g?(le=()=>g("new"),t[71]=g,t[72]=le):le=t[72];let oe;t[73]===Symbol.for("react.memo_cache_sentinel")?(oe=s.jsx(Fe,{size:16}),t[73]=oe):oe=t[73];let ne;t[74]!==e?(ne=e("settings.roles.createRole"),t[74]=e,t[75]=ne):ne=t[75];let de;t[76]!==le||t[77]!==ne?(de=s.jsx(se.Actions,{children:s.jsxs(re,{size:"sm",onClick:le,children:[oe,ne]})}),t[76]=le,t[77]=ne,t[78]=de):de=t[78];let me;t[79]!==J||t[80]!==de?(me=s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[J,de]}),t[79]=J,t[80]=de,t[81]=me):me=t[81];let ue;t[82]!==l||t[83]!==e?(ue=l?s.jsx(ot,{title:e("settings.roles.noRolesFound"),description:e("settings.roles.noRolesMatchSearch",{search:l})}):s.jsx(ot,{title:e("settings.roles.noRoles"),description:e("settings.roles.createRoleGetStarted")}),t[82]=l,t[83]=e,t[84]=ue):ue=t[84];let fe;t[85]!==p||t[86]!==$||t[87]!==te||t[88]!==ue?(fe=s.jsx(ts,{columns:$,data:p,isLoading:!1,onRowClick:te,emptyState:ue}),t[85]=p,t[86]=$,t[87]=te,t[88]=ue,t[89]=fe):fe=t[89];const Be=r!==null;let ye;t[90]===Symbol.for("react.memo_cache_sentinel")?(ye=w=>!w&&n(null),t[90]=ye):ye=t[90];let ge;t[91]!==e?(ge=e("settings.roles.deleteRoleTitle"),t[91]=e,t[92]=ge):ge=t[92];let _e;t[93]!==ge?(_e=s.jsx(ft,{children:ge}),t[93]=ge,t[94]=_e):_e=t[94];const Ue=r?.label??"";let Ee;t[95]!==e||t[96]!==Ue?(Ee=e("settings.roles.deleteRoleConfirm",{role:Ue}),t[95]=e,t[96]=Ue,t[97]=Ee):Ee=t[97];let Te;t[98]!==Ee?(Te=s.jsx(gt,{children:Ee}),t[98]=Ee,t[99]=Te):Te=t[99];let Ae;t[100]!==_e||t[101]!==Te?(Ae=s.jsxs(_t,{children:[_e,Te]}),t[100]=_e,t[101]=Te,t[102]=Ae):Ae=t[102];let Ie;t[103]!==e?(Ie=e("settings.roles.cancel"),t[103]=e,t[104]=Ie):Ie=t[104];let he;t[105]!==Ie?(he=s.jsx(Et,{children:Ie}),t[105]=Ie,t[106]=he):he=t[106];let Re;t[107]!==o||t[108]!==r?(Re=()=>{r?.id&&o.mutate(r.id),n(null)},t[107]=o,t[108]=r,t[109]=Re):Re=t[109];let pe;t[110]!==e?(pe=e("settings.roles.delete"),t[110]=e,t[111]=pe):pe=t[111];let xe;t[112]!==Re||t[113]!==pe?(xe=s.jsx(Tt,{onClick:Re,variant:"destructive",children:pe}),t[112]=Re,t[113]=pe,t[114]=xe):xe=t[114];let Se;t[115]!==he||t[116]!==xe?(Se=s.jsxs(At,{children:[he,xe]}),t[115]=he,t[116]=xe,t[117]=Se):Se=t[117];let Oe;t[118]!==Ae||t[119]!==Se?(Oe=s.jsxs(ut,{children:[Ae,Se]}),t[118]=Ae,t[119]=Se,t[120]=Oe):Oe=t[120];let Ce;t[121]!==Be||t[122]!==Oe?(Ce=s.jsx(mt,{open:Be,onOpenChange:ye,children:Oe}),t[121]=Be,t[122]=Oe,t[123]=Ce):Ce=t[123];let ve;return t[124]!==me||t[125]!==fe||t[126]!==Ce?(ve=s.jsxs(ht,{group:"members",className:"gap-6",children:[me,fe,Ce]}),t[124]=me,t[125]=fe,t[126]=Ce,t[127]=ve):ve=t[127],ve}function nl(t){return t.stopPropagation()}function il(t){return t.stopPropagation()}function rl(t){return s.jsx("span",{className:"text-sm text-foreground",children:t.role.memberCount})}function al(t){return s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:q("size-2.5 rounded-full shrink-0",Rt(t.role.role,t.kind==="builtin"))}),s.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:t.role.label}),t.kind==="builtin"&&s.jsx(at,{size:12,className:"text-muted-foreground shrink-0"})]})}function cl(t,e){Qe("role_delete_failed",{role_id:e,error:t instanceof Error?t.message:String(t)}),Le.error(t instanceof Error?t.message:"Failed to delete role")}function dl(){const t=Y.c(13),e=ee();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={strict:!1},t[0]=l):l=t[0];const{role:i}=It(l);let r;t[1]!==e?(r=e("settings.roles.failedToLoad"),t[1]=e,t[2]=r):r=t[2];let n;t[3]!==r?(n=s.jsx(se,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:r})})}),t[3]=r,t[4]=n):n=t[4];let a;t[5]!==i?(a=i?s.jsx(se,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(we,{className:"size-8 text-muted-foreground"})})}):s.jsx(ht,{group:"members",className:"gap-6",children:s.jsx(kt,{})}),t[5]=i,t[6]=a):a=t[6];let f;t[7]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(ol,{}),t[7]=f):f=t[7];let _;t[8]!==a?(_=s.jsx(F.Suspense,{fallback:a,children:f}),t[8]=a,t[9]=_):_=t[9];let d;return t[10]!==n||t[11]!==_?(d=s.jsx(Bt,{fallback:n,children:_}),t[10]=n,t[11]=_,t[12]=d):d=t[12],d}function xo(){const t=Y.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(sl,{area:"roles",children:s.jsx(dl,{})}),t[0]=e):e=t[0],e}export{xo as default};