// # Generated by tools/generate_components.R. Do not edit by hand.

const binding = new Shiny.InputBinding();

$.extend(binding, {
  find(scope) {
    return $(scope).find('wa-radio-group[id]');
  },

  getId(el) {
    return el.id;
  },

  getValue(el) {
    if (Array.isArray(el.value)) {
      return el.value;
    }
    return el.value;
  },


  subscribe(el, callback) {
    el.__shinyWebawesomeCallback = () => callback();
    el.__shinyWebawesomeEvents = ["change"];
    el.__shinyWebawesomeEvents.forEach((eventName) => {
      el.addEventListener(eventName, el.__shinyWebawesomeCallback);
    });
  },

  unsubscribe(el, callback) {
    if (el.__shinyWebawesomeCallback) {
      (el.__shinyWebawesomeEvents || []).forEach((eventName) => {
        el.removeEventListener(eventName, el.__shinyWebawesomeCallback);
      });
      delete el.__shinyWebawesomeEvents;
      delete el.__shinyWebawesomeCallback;
    }
  },

  receiveMessage(el, data) {
    if (Object.prototype.hasOwnProperty.call(data, "value")) { el.value = data.value; }
    if (Object.prototype.hasOwnProperty.call(data, "label")) { el.label = data.label; }
    if (Object.prototype.hasOwnProperty.call(data, "hint")) { el.hint = data.hint; }
    if (Object.prototype.hasOwnProperty.call(data, "disabled")) { el.disabled = !!data.disabled; }
    el.dispatchEvent(new Event('change', { bubbles: true }));
  }
});

Shiny.inputBindings.register(binding, 'shiny.webawesome.wa_radio_group');
