import BaseComponent from 'primevue/basecomponent';
import InputSwitchStyle from 'primevue/inputswitch/style';
import { openBlock, createElementBlock, mergeProps, toDisplayString, createCommentVNode, createElementVNode } from 'vue';

var script$1 = {
  name: 'BaseInputSwitch',
  "extends": BaseComponent,
  props: {
    modelValue: {
      type: null,
      "default": false
    },
    trueValue: {
      type: null,
      "default": true
    },
    falseValue: {
      type: null,
      "default": false
    },
    invalid: {
      type: Boolean,
      "default": false
    },
    disabled: {
      type: Boolean,
      "default": false
    },
    readonly: {
      type: Boolean,
      "default": false
    },
    tabindex: {
      type: Number,
      "default": null
    },
    inputId: {
      type: String,
      "default": null
    },
    inputClass: {
      type: [String, Object],
      "default": null
    },
    inputStyle: {
      type: Object,
      "default": null
    },
    ariaLabelledby: {
      type: String,
      "default": null
    },
    ariaLabel: {
      type: String,
      "default": null
    },
    activeText: {
      type: String,
      "default": null
    },
    inactiveText: {
      type: String,
      "default": null
    },
    align: {
      type: String,
      "default": null
    },
    tableCellEditor: {
      type: Boolean,
      "default": false
    }
  },
  style: InputSwitchStyle,
  provide: function provide() {
    return {
      $parentInstance: this
    };
  }
};

script$1.__file = "components/lib/inputswitch/BaseInputSwitch.vue";

var script = {
  name: 'InputSwitch',
  "extends": script$1,
  inheritAttrs: false,
  emits: ['update:modelValue', 'change', 'focus', 'blur'],
  methods: {
    getPTOptions: function getPTOptions(key) {
      var _ptm = key === 'root' ? this.ptmi : this.ptm;
      return _ptm(key, {
        context: {
          checked: this.checked,
          disabled: this.disabled
        }
      });
    },
    onChange: function onChange(event) {
      if (!this.disabled && !this.readonly) {
        var newValue = this.checked ? this.falseValue : this.trueValue;
        this.$emit('update:modelValue', newValue);
        this.$emit('change', event);
      }
    },
    onFocus: function onFocus(event) {
      this.$emit('focus', event);
    },
    onBlur: function onBlur(event) {
      this.$emit('blur', event);
    }
  },
  computed: {
    checked: function checked() {
      return this.modelValue === this.trueValue;
    }
  }
};

var _hoisted_1 = ["data-p-highlight", "data-p-disabled"];
var _hoisted_2 = {
  key: 0,
  "class": "p-inputswitch-inactiveText mr-2"
};
var _hoisted_3 = ["id", "checked", "tabindex", "disabled", "readonly", "aria-checked", "aria-labelledby", "aria-label", "aria-invalid"];
var _hoisted_4 = {
  key: 1,
  "class": "p-inputswitch-activeText ml-2"
};
function render(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createElementBlock("div", mergeProps({
    "class": _ctx.cx('root'),
    style: _ctx.sx('root')
  }, $options.getPTOptions('root'), {
    "data-p-highlight": $options.checked,
    "data-p-disabled": _ctx.disabled
  }), [_ctx.inactiveText ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(_ctx.inactiveText), 1 /* TEXT */)) : createCommentVNode("v-if", true), createElementVNode("input", mergeProps({
    id: _ctx.inputId,
    type: "checkbox",
    role: "switch",
    "class": [_ctx.cx('input'), _ctx.inputClass],
    style: _ctx.inputStyle,
    checked: $options.checked,
    tabindex: _ctx.tabindex,
    disabled: _ctx.disabled,
    readonly: _ctx.readonly,
    "aria-checked": $options.checked,
    "aria-labelledby": _ctx.ariaLabelledby,
    "aria-label": _ctx.ariaLabel,
    "aria-invalid": _ctx.invalid || undefined,
    onFocus: _cache[0] || (_cache[0] = function () {
      return $options.onFocus && $options.onFocus.apply($options, arguments);
    }),
    onBlur: _cache[1] || (_cache[1] = function () {
      return $options.onBlur && $options.onBlur.apply($options, arguments);
    }),
    onChange: _cache[2] || (_cache[2] = function () {
      return $options.onChange && $options.onChange.apply($options, arguments);
    })
  }, $options.getPTOptions('input')), null, 16 /* FULL_PROPS */, _hoisted_3), createElementVNode("span", mergeProps({
    "class": _ctx.cx('slider')
  }, $options.getPTOptions('slider')), null, 16 /* FULL_PROPS */), _ctx.activeText ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(_ctx.activeText), 1 /* TEXT */)) : createCommentVNode("v-if", true)], 16 /* FULL_PROPS */, _hoisted_1);
}

script.render = render;
script.__file = "components/lib/inputswitch/InputSwitch.vue";

export { script as default };
