Rewrite this Jinja template to JS for use in Button-card

I need a JS template for my button-card to display an overlay, based on the state of a device_tracker. I can write these for each device rocker individually like below, but would optimally use the JS template in the button-templates for the button-card, and simply create the button with the entity, so the template picksup that entity and resales the correct values

         {% set person = states.device_tracker.life360_name %}
          {% set zones = states.zone | map(attribute='name')|list %}
           {% if person.state == 'home' %} ' '
          {% elif person.attributes.country_code and person.attributes.country_code != 'nl' and 
                person.state not in zones and 
                person.state not in ['moving', 'driving'] %}
           /local/zones/overlay_{{person.attributes.country_code}}.png
          {% else %} 
          /local/zones/overlay_{{person.state|lower|replace(' ','_')}}.png
          {% endif %}

please hope me create that in the rudimentary form of

button_overlay:
  custos_fields:
    overlay_image: >
       [[[
       var person = entity.state;
       var zones = ??
       if (person.state == 'home') return ' ';
       if (person.attributes.country_code and person.attributes.country_code != 'nl'
           and person.state not in zones and 
                person.state not in ['moving', 'driving'] ) return ' /local/zones/overlay_' + person.attributes.country_code + '.png';
       else return '/local/zones/overlay_' + person.state|lower|replace(' ','_') + '.png';
       ]]]