{% set icon = _args.icon|default(null) %}
{% set text = _args.text|default(null) %}
{% set image = _args.image|default(null) %}
{% set type = _args.type|default('button') %}
{% set styles = _args.styles|default(['default']) %}
{% set dropdown = _args.dropdown|default(null) %}
{% set drop = _args.drop|default('down') %}
{% set modal = _args.modal|default(null) %}
{% set sidepanel = _args.sidepanel|default(null) %}
{% set attr = _args.attr|default({}) %}
{% set class = attr.class|default('') %}
{% set churnzero = _args.churnzero|default(null) %}
{% if styles is not iterable %}
{% set styles = styles|split(' ') %}
{% endif %}
{% if text is empty and icon is not empty %}
{% set styles = styles|merge(['icon']) %}
{% endif %}
{% if dropdown %}
{% set styles = styles|merge(['dropdown']) %}
{% set class = (class is not empty ? class ~ ' hc-button--dropdown hc-dropdown-toggle-button' : 'hc-button--dropdown hc-dropdown-toggle-button') %}
{% if dropdown.caret is defined and dropdown.caret %}
{% set class = class ~ ' hc-button--dropdown--add-caret' %}
{% endif %}
{% endif %}
{% set attr = attr|merge({
class: 'hc-button hc-button--%s %s'|format(
styles|join(' hc-button--')|trim,
class,
)|trim,
type: type,
'data-toggle': sidepanel ? 'sidepanel' : null,
'data-target': sidepanel ? ('#' ~ sidepanel) : (modal ? ('#' ~ modal) : null),
'data-churnzero': churnzero and churnzero.event is defined ? churnzero.event : null,
'data-churnzero-extras': churnzero and churnzero.extras is defined ? churnzero.extras|json_encode : null,
}) %}
{% if text %}
{% set attr = attr|merge({'aria-label': text}) %}
{% endif %}
<button {{ attributes(attr) }}>
{% if block('content') is defined %}
{{ block('content') }}
{% else %}
{% if icon %}
{% include 'hc/icon.html.twig' with (icon is iterable ? icon : {
glyph: icon,
}) %}
{% endif %}
{% if text %}{{ text }}{% endif %}
{% endif %}
</button>