async function initializeEventDropdown(container, fieldMappings = null) {
  const eventSelect = container.querySelector('.event-name-dropdown');
  const selectedEventValue = eventSelect.value;

  console.log(`initializeEventDropdown - Initial selected event: ${selectedEventValue}`);

  let fieldNameContainer = container.querySelector('.field-name-container');
  let choicesContainer = container.querySelector('.choices-container');
  let buttonContainer = container.querySelector('.button-container');
  let toggleContainer = container.querySelector('.toggle-container');

  if (!fieldNameContainer) {
    fieldNameContainer = document.createElement('div');
    fieldNameContainer.classList.add('col-md-2', 'field-name-container');
    container.appendChild(fieldNameContainer);
  }

  if (!choicesContainer) {
    choicesContainer = document.createElement('div');
    choicesContainer.classList.add('col-md-2', 'choices-container');
    container.appendChild(choicesContainer);
  }

  if (!buttonContainer) {
    buttonContainer = document.createElement('div');
    buttonContainer.classList.add('col-md-3', 'button-container');
    buttonContainer.style.marginTop = '25px';
    container.appendChild(buttonContainer);
  }

  if (!toggleContainer) {
    toggleContainer = document.createElement('div');
    toggleContainer.classList.add('col-md-2', 'toggle-container');
    toggleContainer.style.marginLeft = 'auto';
    toggleContainer.style.marginRight = '5px';
    toggleContainer.style.marginTop = '30px';
    container.appendChild(toggleContainer);
  }

  // Create and append the toggle switch
  const toggleSwitch = document.createElement('fw-toggle');
  toggleSwitch.setAttribute('size', 'medium');
  toggleSwitch.checked = fieldMappings?.combinations[0]?.isEnabled || false;
  toggleContainer.appendChild(toggleSwitch);

  // Create and append the delete button next to it
  const deleteButton = document.createElement('button');
  deleteButton.textContent = 'Delete Event';
  deleteButton.classList.add('btn', 'btn-danger', 'ml-2'); // Add some margin to separate from the toggle
  toggleContainer.appendChild(deleteButton);

  if (fieldMappings && fieldMappings.combinations.length > 0) {
    const fields = fieldMappings.combinations[0].fields;
    for (const [fieldName, fieldValue] of Object.entries(fields)) {
      await fieldschoosingvalues(selectedEventValue, fieldNameContainer, choicesContainer, buttonContainer, container, fieldName, [fieldValue]);
    }
  }

  toggleSwitch.addEventListener('fwChange', (event) => {
    const isChecked = event.target.checked;
    updateDropdownAccessibility(isChecked);
    updateIsEnabledState(selectedEventValue, isChecked);
  });

  deleteButton.addEventListener('click', () => {
    deleteEvent(container, selectedEventValue);
  });

  updateIsEnabledState(selectedEventValue, toggleSwitch.checked); // Initial state capture

  function updateDropdownAccessibility(isEnabled) {
    const dropdowns = container.querySelectorAll('.choices-dropdown, .field-name-dropdown, .event-name-dropdown');
    dropdowns.forEach(dropdown => {
      dropdown.disabled = !isEnabled;
    });
  }

  function updateIsEnabledState(selectedEventValue, isChecked) {
    if (!selectedEventValue) {
      console.error("Event is not selected.");
      return;
    }

    if (!ticketworkflowconditions[selectedEventValue]) {
      ticketworkflowconditions[selectedEventValue] = { combinations: [{ isEnabled: isChecked, fields: {} }] };
    }

    let combination = ticketworkflowconditions[selectedEventValue].combinations[0];
    combination.isEnabled = isChecked;

    console.log(`Toggle for ${selectedEventValue} set to ${isChecked ? 'enabled' : 'disabled'}.`);
    console.log(`Updated ticketworkflowconditions after toggle change: ${JSON.stringify(ticketworkflowconditions, null, 2)}`);
  }
}

function deleteEvent(container, eventValue) {
  // Remove the event data from ticketworkflowconditions
  if (ticketworkflowconditions[eventValue]) {
    delete ticketworkflowconditions[eventValue];
  }

  // Remove the UI container for the event
  container.remove();

  console.log(`Event ${eventValue} removed from ticketworkflowconditions and DOM.`);
  console.log(`Updated ticketworkflowconditions: ${JSON.stringify(ticketworkflowconditions, null, 2)}`);
}


it should remove entire container (ui too)

also change the button to 

  <fw-button color="danger"> Delete Event</fw-button>