export type WidgetEventTriggerData = {
  eventCode: string
  direction?: string
  key?: string
}

export type WidgetEventTargetKind =
  | 'widget'
  | 'page'
  | 'custom_code'
  | 'load_page'
  | 'language_switch'
  | 'theme_switch'

export type WidgetEventTargetData = {
  kind: WidgetEventTargetKind
  pageId?: string
  screenId?: string
  targetId?: string
  targetType?: string
}

export type WidgetEventActionData = {
  actionKey: string
}

export type WidgetEventAction = {
  id: string
  name: string
  nodeType: 'action'
  value?: any
  config?: {
    data?: {
      targetData?: WidgetEventTargetData
      actionData?: WidgetEventActionData
      kind?: WidgetEventTargetKind
    }
    [key: string]: any
  }
}

export type WidgetEventTarget = {
  id: string
  name: string
  value?: string
  nodeType: 'target'
  config?: {
    data?: WidgetEventTargetData
    [key: string]: any
  }
  children?: WidgetEventAction[]
}

export type WidgetEvent = {
  id: string
  name: string
  value?: string
  nodeType: 'event'
  config?: {
    data?: WidgetEventTriggerData
    [key: string]: any
  }
  children?: WidgetEventTarget[]
}
