import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{At as s}from"./vendor-all-0-fRSUBfCr.js";import{Ll as n,Tb as a,Vm as i,zm as r}from"./shared-0-C4kdVF7Y.js";import{Mi as o,ki as t}from"./vendor-frame-CwiylG4Y.js";import{At as d}from"./vendor-all-1-BfXMvJfI.js";import{rn as c}from"./vendor-all-2-BJdkbLSj.js";import{$ as l,O as m,R as u}from"./shared-frame-DbQbH4Yr.js";import{I as f,Un as g}from"./shared-4-6CEyRAHb.js";import{Ts as h}from"./shared-5-UQAFGbWu.js";import{W as p,pr as _}from"./shared-14-BNdP3DJt.js";var b="ccr-channel-config";function v(e){return!0===e?.effective_disabled&&!0!==e.config?.disabled}function x(e){return e instanceof a&&400===e.statusCode&&"channel_disable_write_disabled_error"===e.type}function j(e){return{"anthropic-version":"2023-06-01","anthropic-beta":"ccr-triggers-2026-01-30",...e?{"x-organization-uuid":e}:{}}}var z=/^[A-Z0-9]{1,32}$/;function y(e){return z.test(e)?e:"invalid-slack-id"}function k(e,s){return`/v1/code/slack/channels/${y(e)}/${y(s)}/config`}var w=(e,s)=>{const{activeOrganization:a}=n(),r=a?.uuid;return i(k(e,s),{queryKey:[b,{orgUuid:r,slackTeamId:e,slackChannelId:s}],enabled:Boolean(a&&e&&s),headers:j(r),meta:{noToast:!0}})};var N=(e,a)=>{const{activeOrganization:i}=n(),o=s(),t=i?.uuid;return r(k(e,a),"POST",{onSuccess:(s,n)=>{o.setQueryData([b,{orgUuid:t,slackTeamId:e,slackChannelId:a}],e=>function(e,s,n){if(!s.config)return s;const a=s.config.disabled??n?.disabled??e?.config?.disabled;return{...e,...s,effective_disabled:v(e)||!0===a,config:{...e?.config,...s.config,disabled:a,system_prompt_addendum:s.config.system_prompt_addendum??(n?.clear_system_prompt_addendum?"":e?.config?.system_prompt_addendum),resolved_connections:s.config.resolved_connections?.length?s.config.resolved_connections:e?.config?.resolved_connections,resolved_github_repos:s.config.resolved_github_repos?.length?s.config.resolved_github_repos:e?.config?.resolved_github_repos,resolved_source_urls:s.config.resolved_source_urls?.length?s.config.resolved_source_urls:e?.config?.resolved_source_urls,member_config_disabled:s.config.member_config_disabled??e?.config?.member_config_disabled,channel_name:s.config.channel_name||e?.config?.channel_name}}}(e,s,n))},meta:{noToast:!0},headers:j(t)})},T=e(o()),O=t();function I(){const e=c(),{account:s,activeOrganization:a}=n(),{switchAndRefresh:i}=g(),r=f(),o=(0,T.useMemo)(()=>d((s?.memberships??[]).filter(e=>e.organization.capabilities.includes("chat")&&e.organization.capabilities.includes("raven")),e=>e.organization.name),[s?.memberships]);if(!a)return null;const t=!!a.has_icon;return(0,O.jsx)(m,{align:"start",items:o.map(s=>{const n=s.organization,o=n.uuid===a.uuid,t=!o&&null!==r&&!r.includes(n.uuid.toLowerCase());return{label:n.name,leading:(0,O.jsx)("span",{"aria-hidden":!0,children:(0,O.jsx)(p,{org:n})}),description:t?e.formatMessage({defaultMessage:"Restricted by your admin",id:"QeMzvK0zhW"}):void 0,checked:o,checkedRole:"radio",keepOpen:o,disabled:t,onSelect:o?void 0:()=>i(n.uuid)}}),renderTrigger:(0,O.jsxs)(u,{variant:"secondary",size:"sm",icon:(0,O.jsx)("span",{"aria-hidden":!0,className:"inline-flex",children:t?(0,O.jsx)(_,{organization:a,size:"sm"}):(0,O.jsx)(l,{name:"Organization",size:"sm",className:"text-muted"})}),"data-testid":"admin-settings-org-switcher",className:"mb-4 w-full [&>span:not([aria-hidden])]:w-full [&>span:not([aria-hidden])]:min-w-0",children:[(0,O.jsx)("span",{className:"min-w-0 flex-1 truncate text-left",children:a.name}),(0,O.jsx)(l,{name:"CaretDown",size:"sm",className:"shrink-0 opacity-60"})]})})}function C({surfaceIconSrc:e="/images/install-hub/slack-icon.svg"}){return(0,O.jsxs)("span",{"aria-hidden":!0,className:"mb-md flex items-center font-normal",children:[(0,O.jsx)("span",{className:"flex size-[34px] rotate-[2.8deg] items-center justify-center rounded-lg bg-fill-brand",children:(0,O.jsx)(h,{size:24,color:"var(--cds-on-brand)"})}),(0,O.jsx)("span",{className:"mx-1 h-0 w-[23px] border-t-[1.4px] border-dashed border-alpha-3"}),(0,O.jsx)("span",{className:"flex size-[34px] -rotate-3 items-center justify-center rounded-[10px] border border-alpha-2 bg-surface-1 shadow-sm",children:(0,O.jsx)("img",{loading:"lazy",src:e,alt:"",width:20,height:20})})]})}export{v as a,x as i,I as n,w as o,z as r,N as s,C as t};