package DX::Resolution;

use DX::Utils qw(expand_deps);
use DX::Class;

has veracity_depends_on => (is => 'ro', required => 1, isa => DependencyList);

has actions => (is => 'ro', required => 1, isa => ArrayRef[Action]);

sub next_resolution { $_[0] }

sub remainder { () }

sub for_deparse {
  my ($self) = @_;
  [ word_and_body => [
    'resolution',
    [ pairs => [
      (@{$self->actions}
        ? [ actions => [ block => $self->actions ] ]
        : ()),
      [ veracity_depends_on => [ block => [
        map [ statement => [
          [ symbol => (split '::', ${$_->[0]})[-1] ],
          [ value_path => [ @{$_}[1..$#$_] ] ],
        ] ], @{expand_deps($self->veracity_depends_on)}
      ] ] ],
    ] ],
  ] ];
}

1;
