import type { FileOpenAction, LineAction, UrlOpenAction } from './types'

export function noneAction(): LineAction {
  return { type: 'none' }
}

export function selectToolCallAction(callId: string): LineAction {
  return { type: 'selectToolCall', callId }
}

export function openApprovalAction(): LineAction {
  return { type: 'openApproval' }
}

export function toolApprovalAction(
  requestId: string,
  action: 'approve' | 'alwaysApprove' | 'deny',
): LineAction {
  return { type: 'toolApproval', requestId, action }
}

export function askUserOptionAction(
  toolCallId: string,
  questionIndex: number,
  optionIndex: number,
): LineAction {
  return { type: 'askUserOption', toolCallId, questionIndex, optionIndex }
}

export function askUserNavAction(
  toolCallId: string,
  direction: 'prev' | 'next',
): LineAction {
  return { type: 'askUserNav', toolCallId, direction }
}

export function askUserSubmitAction(toolCallId: string): LineAction {
  return { type: 'askUserSubmit', toolCallId }
}

export function askUserCancelAction(toolCallId: string): LineAction {
  return { type: 'askUserCancel', toolCallId }
}

export function openFileAction(absPath: string): FileOpenAction {
  return { type: 'openFile', absPath }
}

export function openUrlAction(url: string): UrlOpenAction {
  return { type: 'openUrl', url }
}

export function toggleItemAction(
  messageId: string,
  part: 'todo' | 'plan',
  itemId: string,
): LineAction {
  return { type: 'toggleItem', messageId, part, itemId }
}

export function toggleCollapseAction(
  messageId: string,
  part: 'todo' | 'plan' | 'thinking',
  partId: string,
): LineAction {
  return { type: 'toggleCollapse', messageId, part, partId }
}

export function showMessageActionsAction(messageId: string): LineAction {
  return { type: 'showMessageActions', messageId }
}

export function revertFilesAction(messageId: string): LineAction {
  return { type: 'revertFiles', messageId }
}

export function toggleBashOutputAction(toolCallId: string): LineAction {
  return { type: 'toggleBashOutput', toolCallId }
}

export function loadMoreBashOutputAction(toolCallId: string): LineAction {
  return { type: 'loadMoreBashOutput', toolCallId }
}

export function toggleEditDiffLayoutAction(toolCallId: string): LineAction {
  return { type: 'toggleEditDiffLayout', toolCallId }
}

export function selectToolCallGroupAction(groupKey: string): LineAction {
  return { type: 'selectToolCallGroup', groupKey }
}

export function copyTextAction(text: string): LineAction {
  return { type: 'copyText', text }
}
