How to nest with javascript in dashboard cards?

Hello everyone,
I have been struggling for a while to figure out how to nest options in cards supporting javascript.

I am trying to make the whole statistics part conditional.

        options:
          yaxis_id: |-
            ${ 
              if (states['input_select.dropdown_wildcards'].state == 'eQ-3 Valve')
                { 'second' }
              else
                { 'first' }
              }
          statistics:
            type: max
            period: 5minute
            align: start

The card does not allow for statistics to have empty sub-options. So I need to conditonally add or remove statisticsincluding the three sub-options.

Does anybody know how to get this working?

thank you very much for your help
Alex

P.S.:
I tried using line breaks and tabs, but either I missed something or my approach did not work.

        options: |-
          ${
            if (states['input_text.text_wildcards'].state != '')
              { '\t\t\t\t\tyaxis_id: |-\n
              \t\t\t\t\t\t${\n
              \t\t\t\t\t\t\tif (states['input_select.dropdown_wildcards'].state == 'eQ-3 Valve')\n
              \t\t\t\t\t\t\t\t{ 'second' }\n
              \t\t\t\t\t\t\telse\n
              \t\t\t\t\t\t\t\t{ 'first' }\n
              \t\t\t\t\t\t\t}\n
              \t\t\t\t\tstatistics:\n
              \t\t\t\t\t\ttype: max\n
              \t\t\t\t\t\tperiod: |-\n
              \t\t\t\t\t\t\t${\n
              \t\t\t\t\t\t\t\tif ( ((states['input_datetime.end_datetime'].attributes.timestamp-states['input_datetime.start_datetime'].attributes.timestamp)/60/60).toFixed(2)>=25 && ((states['input_datetime.end_datetime'].attributes.timestamp-states['input_datetime.start_datetime'].attributes.timestamp)/60/60).toFixed(2)<168 )\n
              \t\t\t\t\t\t\t\t\t{ '5minute' }\n
              \t\t\t\t\t\t\t\telse\n
              \t\t\t\t\t\t\t\t\t{ 'hour' }\n
              \t\t\t\t\t\t\t\t}\n
              \t\t\t\t\t\talign: start\n' }
          }