import{hasVercelProject}from"../state.js";import{SCAFFOLDABLE_CHANNELS}from"#setup/scaffold/index.js";function selectChannels(n){let r=n.variant===`channels-add`,i=n.variant===`in-project`;function assertSlackHasVercel(e,t){if(e&&t.includes(`slack`))throw Error("Slack requires a Vercel project. Link this directory (`vercel link`) and re-run to add Slack.")}function slackLacksVercel(t){return i&&!hasVercelProject(t)}return{id:`select-channels`,async gather({state:e}){let i=slackLacksVercel(e);if(n.presetChannels!==void 0)return assertSlackHasVercel(i,n.presetChannels),await n.validateSelection?.(n.presetChannels),n.presetChannels;let a=SCAFFOLDABLE_CHANNELS.map(e=>{let t=n.disabledChannelReasons?.[e.kind];return t===void 0?i&&e.kind===`slack`?{id:e.kind,value:e.kind,label:e.label,disabled:!0,disabledReason:`needs a Vercel project`}:{id:e.kind,value:e.kind,label:e.label,hint:e.hint}:{id:e.kind,value:e.kind,label:e.label,hint:e.hint,disabled:!0,disabledReason:t}}),o={id:`tui`,value:`tui`,label:`CLI REPL`,locked:!0,lockedReason:`always available`},s=await n.asker.askMany({key:`channels`,message:`Where will you chat with your agent?`,options:r?a:[...a,o],required:!0,requireSelection:!r});assertSlackHasVercel(i,s);let c=s.filter(e=>e!==`tui`);return await n.validateSelection?.(c),c},async perform({input:e}){return e},apply(e,t){return{...e,channelSelection:t}}}}export{selectChannels};