import {
  useExpose
} from "./chunk-7XAXYYDR.js";
import {
  Icon
} from "./chunk-D5TWCK54.js";
import {
  addUnit,
  createNamespace,
  extend,
  makeArrayProp,
  makeRequiredProp,
  makeStringProp,
  numericProp,
  pick,
  truthProp,
  unknownProp,
  useChildren,
  useCustomFieldValue,
  useParent,
  withInstall
} from "./chunk-6TMJMNX7.js";

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/checkbox/Checkbox.mjs
import { watch as watch2, computed as computed2, defineComponent as defineComponent3, mergeProps as _mergeProps, createVNode as _createVNode3 } from "vue";

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/checkbox-group/CheckboxGroup.mjs
import { watch, defineComponent, createVNode as _createVNode } from "vue";
var [name, bem] = createNamespace("checkbox-group");
var checkboxGroupProps = {
  max: numericProp,
  shape: makeStringProp("round"),
  disabled: Boolean,
  iconSize: numericProp,
  direction: String,
  modelValue: makeArrayProp(),
  checkedColor: String
};
var CHECKBOX_GROUP_KEY = Symbol(name);
var stdin_default = defineComponent({
  name,
  props: checkboxGroupProps,
  emits: ["change", "update:modelValue"],
  setup(props, {
    emit,
    slots
  }) {
    const {
      children,
      linkChildren
    } = useChildren(CHECKBOX_GROUP_KEY);
    const updateValue = (value) => emit("update:modelValue", value);
    const toggleAll = (options = {}) => {
      if (typeof options === "boolean") {
        options = {
          checked: options
        };
      }
      const {
        checked,
        skipDisabled
      } = options;
      const checkedChildren = children.filter((item) => {
        if (!item.props.bindGroup) {
          return false;
        }
        if (item.props.disabled && skipDisabled) {
          return item.checked.value;
        }
        return checked != null ? checked : !item.checked.value;
      });
      const names = checkedChildren.map((item) => item.name);
      updateValue(names);
    };
    watch(() => props.modelValue, (value) => emit("change", value));
    useExpose({
      toggleAll
    });
    useCustomFieldValue(() => props.modelValue);
    linkChildren({
      props,
      updateValue
    });
    return () => {
      var _a;
      return _createVNode("div", {
        "class": bem([props.direction])
      }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
    };
  }
});

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/checkbox/Checker.mjs
import { ref, computed, defineComponent as defineComponent2, createVNode as _createVNode2 } from "vue";
var checkerProps = {
  name: unknownProp,
  disabled: Boolean,
  iconSize: numericProp,
  modelValue: unknownProp,
  checkedColor: String,
  labelPosition: String,
  labelDisabled: Boolean
};
var stdin_default2 = defineComponent2({
  props: extend({}, checkerProps, {
    bem: makeRequiredProp(Function),
    role: String,
    shape: String,
    parent: Object,
    checked: Boolean,
    bindGroup: truthProp,
    indeterminate: {
      type: Boolean,
      default: null
    }
  }),
  emits: ["click", "toggle"],
  setup(props, {
    emit,
    slots
  }) {
    const iconRef = ref();
    const getParentProp = (name3) => {
      if (props.parent && props.bindGroup) {
        return props.parent.props[name3];
      }
    };
    const disabled = computed(() => {
      if (props.parent && props.bindGroup) {
        const disabled2 = getParentProp("disabled") || props.disabled;
        if (props.role === "checkbox") {
          const checkedCount = getParentProp("modelValue").length;
          const max = getParentProp("max");
          const overlimit = max && checkedCount >= +max;
          return disabled2 || overlimit && !props.checked;
        }
        return disabled2;
      }
      return props.disabled;
    });
    const direction = computed(() => getParentProp("direction"));
    const iconStyle = computed(() => {
      const checkedColor = props.checkedColor || getParentProp("checkedColor");
      if (checkedColor && (props.checked || props.indeterminate) && !disabled.value) {
        return {
          borderColor: checkedColor,
          backgroundColor: checkedColor
        };
      }
    });
    const shape = computed(() => {
      return props.shape || getParentProp("shape") || "round";
    });
    const onClick = (event) => {
      const {
        target
      } = event;
      const icon = iconRef.value;
      const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
      if (!disabled.value && (iconClicked || !props.labelDisabled)) {
        emit("toggle");
      }
      emit("click", event);
    };
    const renderIcon = () => {
      var _a, _b;
      const {
        bem: bem3,
        checked,
        indeterminate
      } = props;
      const iconSize = props.iconSize || getParentProp("iconSize");
      return _createVNode2("div", {
        "ref": iconRef,
        "class": bem3("icon", [shape.value, {
          disabled: disabled.value,
          checked,
          indeterminate
        }]),
        "style": shape.value !== "dot" ? {
          fontSize: addUnit(iconSize)
        } : {
          width: addUnit(iconSize),
          height: addUnit(iconSize),
          borderColor: (_a = iconStyle.value) == null ? void 0 : _a.borderColor
        }
      }, [slots.icon ? slots.icon({
        checked,
        disabled: disabled.value
      }) : shape.value !== "dot" ? _createVNode2(Icon, {
        "name": indeterminate ? "minus" : "success",
        "style": iconStyle.value
      }, null) : _createVNode2("div", {
        "class": bem3("icon--dot__icon"),
        "style": {
          backgroundColor: (_b = iconStyle.value) == null ? void 0 : _b.backgroundColor
        }
      }, null)]);
    };
    const renderLabel = () => {
      const {
        checked
      } = props;
      if (slots.default) {
        return _createVNode2("span", {
          "class": props.bem("label", [props.labelPosition, {
            disabled: disabled.value
          }])
        }, [slots.default({
          checked,
          disabled: disabled.value
        })]);
      }
    };
    return () => {
      const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
      return _createVNode2("div", {
        "role": props.role,
        "class": props.bem([{
          disabled: disabled.value,
          "label-disabled": props.labelDisabled
        }, direction.value]),
        "tabindex": disabled.value ? void 0 : 0,
        "aria-checked": props.checked,
        "onClick": onClick
      }, [nodes]);
    };
  }
});

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/checkbox/Checkbox.mjs
var [name2, bem2] = createNamespace("checkbox");
var checkboxProps = extend({}, checkerProps, {
  shape: String,
  bindGroup: truthProp,
  indeterminate: {
    type: Boolean,
    default: null
  }
});
var stdin_default3 = defineComponent3({
  name: name2,
  props: checkboxProps,
  emits: ["change", "update:modelValue"],
  setup(props, {
    emit,
    slots
  }) {
    const {
      parent
    } = useParent(CHECKBOX_GROUP_KEY);
    const setParentValue = (checked2) => {
      const {
        name: name22
      } = props;
      const {
        max,
        modelValue
      } = parent.props;
      const value = modelValue.slice();
      if (checked2) {
        const overlimit = max && value.length >= +max;
        if (!overlimit && !value.includes(name22)) {
          value.push(name22);
          if (props.bindGroup) {
            parent.updateValue(value);
          }
        }
      } else {
        const index = value.indexOf(name22);
        if (index !== -1) {
          value.splice(index, 1);
          if (props.bindGroup) {
            parent.updateValue(value);
          }
        }
      }
    };
    const checked = computed2(() => {
      if (parent && props.bindGroup) {
        return parent.props.modelValue.indexOf(props.name) !== -1;
      }
      return !!props.modelValue;
    });
    const toggle = (newValue = !checked.value) => {
      if (parent && props.bindGroup) {
        setParentValue(newValue);
      } else {
        emit("update:modelValue", newValue);
      }
      if (props.indeterminate !== null)
        emit("change", newValue);
    };
    watch2(() => props.modelValue, (value) => {
      if (props.indeterminate === null)
        emit("change", value);
    });
    useExpose({
      toggle,
      props,
      checked
    });
    useCustomFieldValue(() => props.modelValue);
    return () => _createVNode3(stdin_default2, _mergeProps({
      "bem": bem2,
      "role": "checkbox",
      "parent": parent,
      "checked": checked.value,
      "onToggle": toggle
    }, props), pick(slots, ["default", "icon"]));
  }
});

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/checkbox/index.mjs
var Checkbox = withInstall(stdin_default3);
var stdin_default4 = Checkbox;

export {
  checkboxGroupProps,
  stdin_default,
  checkerProps,
  stdin_default2,
  checkboxProps,
  Checkbox,
  stdin_default4 as stdin_default3
};
//# sourceMappingURL=chunk-56XS5CZJ.js.map
