-- An optional function that an Action's onActivated callback can return. This
-- function gets called when the action is being deactivated so it can clean
-- itself up

export type ActionTeardown = () -> ()

export type Action = {
	-- The name of the action. This is shown first in tooltips
	name: string,

	-- A description of the action. This is shown after the name in tooltips
	description: string?,

	-- Icon displayed on the action bar
	icon: string,

	-- Icon displayed on the action bar when the action is active. This can only
	-- be used on parent actions, not sub-actions
	activeIcon: string?,

	-- Optional list of sub-actions. This allows you to create submenus of
	-- various other actions
	actions: { Action }?,

	-- The parent is only set for sub-actions and points to the action that
	-- contains it
	parent: Action?,

	-- Can be set to `true` for a sub-action that acts as the default option
	isDefault: boolean?,

	-- Optional callback that gets run when activating an action or sub-action.
	-- Typically if an action contains sub-actions, only the sub-actions will
	-- have onActivated defined
	onActivated: ((self: Action, store: any) -> ActionTeardown?)?,
}

export type State = {
	-- The last action that was activated. This can be any of the top-level
	-- actions or a sub-action
	lastActivatedAction: Action?,

	-- The current action that was activated that contains sub-actions
	parentAction: Action?,

	-- The active actions are stored in the state so that when an action is
	-- toggled it triggers a re-render.
	activeActions: { Action },

	-- Whether or not the submenu is shown. This happens when an action that has
	-- sub-actions has been activated
	isSubmenuShown: boolean,
}

return {}
