<%# locals: (rule:) %>
">
<% if rule.name.present? %>

<%= rule.name %>

<% end %> <% if rule.conditions.any? %>
IF

<% if rule.conditions.first.compound? %> <%= rule.conditions.first.sub_conditions.first.filter.label %> <%= rule.conditions.first.sub_conditions.first.operator %> <%= rule.conditions.first.sub_conditions.first.value_display %> <% else %> <%= rule.conditions.first.filter.label %> <%= rule.conditions.first.operator %> <%= rule.conditions.first.value_display %> <% end %> <% if rule.conditions.count > 1 %> and <%= rule.conditions.count - 1 %> more <%= rule.conditions.count - 1 == 1 ? "condition" : "conditions" %> <% end %>

<% end %>
THEN

<% if rule.actions.first.value && rule.actions.first.options %> <%= rule.actions.first.executor.label %> to <%= rule.actions.first.value_display %> <% else %> <%= rule.actions.first.executor.label %> <% end %> <% if rule.actions.count > 1 %> and <%= rule.actions.count - 1 %> more <%= rule.actions.count - 1 == 1 ? "action" : "actions" %> <% end %>

FOR

<% if rule.effective_date.nil? %> All past and future <%= rule.resource_type.pluralize %> <% else %> <%= rule.resource_type.pluralize %> on or after <%= rule.effective_date.strftime("%b %-d, %Y") %> <% end %>

<%= styled_form_with model: rule, data: { controller: "auto-submit-form" } do |f| %> <%= f.toggle :active, { data: { auto_submit_form_target: "auto" } } %> <% end %> <%= render MenuComponent.new do |menu| %> <% menu.with_item(variant: "link", text: "Edit", href: edit_rule_path(rule), icon: "pencil", data: { turbo_frame: "modal" }) %> <% menu.with_item(variant: "link", text: "Re-apply rule", href: confirm_rule_path(rule), icon: "refresh-cw", data: { turbo_frame: "modal" }) %> <% menu.with_item( variant: "button", text: "Delete", href: rule_path(rule), icon: "trash-2", method: :delete, confirm: CustomConfirm.for_resource_deletion("rule")) %> <% end %>