"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index = require("../../../hooks/use-namespace/index.js");
const checkbox = require("./checkbox.js");
const constants = require("./constants.js");
const useCheckbox = require("./composables/use-checkbox.js");
const Vue = require("vue");
const _hoisted_1 = [
  "name",
  "tabindex",
  "disabled"
];
var checkbox_button_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElCheckboxButton",
  __name: "checkbox-button",
  props: checkbox.checkboxProps,
  emits: checkbox.checkboxEmits,
  setup(__props) {
    const props = __props;
    const { isFocused, isChecked, isDisabled, checkboxButtonSize, model, actualValue, handleChange } = useCheckbox.useCheckbox(props, Vue.useSlots());
    const inputBindings = Vue.computed(() => {
      if (props.trueValue || props.falseValue || props.trueLabel || props.falseLabel) return {
        "true-value": props.trueValue ?? props.trueLabel ?? true,
        "false-value": props.falseValue ?? props.falseLabel ?? false
      };
      return { value: actualValue.value };
    });
    const checkboxGroup = Vue.inject(constants.checkboxGroupContextKey, void 0);
    const ns = index.useNamespace("checkbox");
    const activeStyle = Vue.computed(() => {
      var _a, _b;
      const fillValue = ((_a = checkboxGroup == null ? void 0 : checkboxGroup.fill) == null ? void 0 : _a.value) ?? "";
      return {
        backgroundColor: fillValue,
        borderColor: fillValue,
        color: ((_b = checkboxGroup == null ? void 0 : checkboxGroup.textColor) == null ? void 0 : _b.value) ?? "",
        boxShadow: fillValue ? `-1px 0 0 0 ${fillValue}` : void 0
      };
    });
    const labelKls = Vue.computed(() => {
      return [
        ns.b("button"),
        ns.bm("button", checkboxButtonSize.value),
        ns.is("disabled", isDisabled.value),
        ns.is("checked", isChecked.value),
        ns.is("focus", isFocused.value)
      ];
    });
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("label", { class: Vue.normalizeClass(labelKls.value) }, [Vue.withDirectives(Vue.createElementVNode("input", Vue.mergeProps({
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(model) ? model.value = $event : null),
        class: Vue.unref(ns).be("button", "original"),
        type: "checkbox",
        name: __props.name,
        tabindex: __props.tabindex,
        disabled: Vue.unref(isDisabled)
      }, inputBindings.value, {
        onChange: _cache[1] || (_cache[1] = (...args) => Vue.unref(handleChange) && Vue.unref(handleChange)(...args)),
        onFocus: _cache[2] || (_cache[2] = ($event) => isFocused.value = true),
        onBlur: _cache[3] || (_cache[3] = ($event) => isFocused.value = false),
        onClick: _cache[4] || (_cache[4] = Vue.withModifiers(() => {
        }, ["stop"]))
      }), null, 16, _hoisted_1), [[Vue.vModelCheckbox, Vue.unref(model)]]), _ctx.$slots.default || __props.label ? (Vue.openBlock(), Vue.createElementBlock("span", {
        key: 0,
        class: Vue.normalizeClass(Vue.unref(ns).be("button", "inner")),
        style: Vue.normalizeStyle(Vue.unref(isChecked) ? activeStyle.value : void 0)
      }, [Vue.renderSlot(_ctx.$slots, "default", {}, () => [Vue.createTextVNode(Vue.toDisplayString(__props.label), 1)])], 6)) : Vue.createCommentVNode("v-if", true)], 2);
    };
  }
});
exports.default = checkbox_button_vue_vue_type_script_setup_true_lang_default;
