{% 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 churnzero = _args.churnzero|default(null) %}
{% if styles is not iterable %}
{% set styles = styles|split(' ') %}
{% endif %}
{% if icon is not empty %}
{% set styles = styles|merge(['icon']) %}
{% endif %}
{% set attr = attr|merge({
class: '%s btn btn-%s %s'|format(
attr.class|default(''),
styles|join(' btn-')|trim,
(dropdown) ? 'dropdown-toggle' : ''
)|trim,
type: type,
'data-toggle': sidepanel ? 'sidepanel' : ((dropdown) ? 'dropdown' : ((modal) ? 'modal' : 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 dropdown %}
<div class="btn-group drop{{- drop -}}">
{% endif %}
<button {{ attributes(attr) }}>
{% if block('content') is defined %}
{{ block('content') }}
{% else %}
{% if image %}
<img src="{{ image }}" />
{% endif %}
{% if text %}{{ text }}{% endif %}
{% if icon %}<i class="{{ icon }}"></i>{% endif %}
{% endif %}
</button>
{% if dropdown %}
{% include '@ui2022/dropdown__menu.html.twig' with dropdown %}
</div>
{% endif %}