<tr>
    <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
        {% if is_edit|default(false, true) == false %}
        {{ exercise_name }}
        {% else %}
        <div class="w-full">
            <select id="topset-exercise-select-{{ topset_id }}" data-te-select-init data-te-select-filter="true"
                data-te-select-size="lg" name="exercise_id"
                class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
                {% for exercise in exercises|default([], true) %}
                <option value="{{ exercise['ExerciseId'] }}">{{
                    exercise['Name']
                    }}</option>
                {% endfor %}
            </select>
        </div>
        <script>
            te.Select.getOrCreateInstance(document.querySelector("#topset-exercise-select-{{ topset_id }}")).setValue("{{ exercise_id }}");
        </script>
        {% endif %}
    </td>
    <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
        {% if is_edit|default(false, true) == false %}
        {{ repetitions }} x {{ weight }}kg
        {% else %}
        <div class="flex items-center">
            <input type="number"
                class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
                name="repetitions" value="{{ repetitions }}">
            <p class="px-2">x</p>
            <input type="number"
                class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
                name="weight" value="{{ weight }}">
            <p class="px-2">kg</p>
        </div>
        {% endif %}
    </td>
    <td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
        {% if is_edit|default(false, true) == false %}
        <a hx-get="{{ url_for('get_topset_edit_form',person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
            class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
            Edit
        </a>
        <a hx-delete="{{ url_for('delete_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
            hx-confirm="Are you sure you wish to delete this topset?"
            class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
            Delete
        </a>
        {% else %}
        <a hx-put="{{ url_for('update_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
            hx-include="[name='exercise_id'], [name='repetitions'], [name='weight']"
            class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
            Update
        </a>
        <a hx-get="{{ url_for('get_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
            class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
            Cancel
        </a>
        {% endif %}

    </td>
</tr>