import { capitalize, computed, createVNode, isVNode } from "vue";
import "./styles/col.scss";
import { makeTagProps } from "../../composables/tag/index.mjs";
import { propsFactory } from "../../utils/dist/index.mjs";
import { defineComponent } from "../../utils/define-component.mjs";
function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
}
const breakpoints = ["sm", "md", "lg", "xl", "xxl"];
const breakpointProps = (() => {
  return breakpoints.reduce((props, val) => {
    props[val] = {
      type: [Boolean, String, Number],
      default: false
    };
    return props;
  }, {});
})();
const offsetProps = (() => {
  return breakpoints.reduce((props, val) => {
    props[`offset${capitalize(val)}`] = {
      type: [String, Number],
      default: null
    };
    return props;
  }, {});
})();
const orderProps = (() => {
  return breakpoints.reduce((props, val) => {
    props[`order${capitalize(val)}`] = {
      type: [String, Number],
      default: null
    };
    return props;
  }, {});
})();
const propMap = {
  col: Object.keys(breakpointProps),
  offset: Object.keys(offsetProps),
  order: Object.keys(orderProps)
};
function breakpointClass(type, prop, val) {
  let className = type;
  if (val == null || val === false) {
    return void 0;
  }
  if (prop) {
    const breakpoint = prop.replace(type, "");
    className += `-${breakpoint}`;
  }
  if (type === "col") {
    className = `ve-${className}`;
  }
  if (type === "col" && (val === "" || val === true)) {
    return className.toLowerCase();
  }
  className += `-${val}`;
  return className.toLowerCase();
}
const makeColProps = propsFactory({
  cols: {
    type: [Boolean, String, Number],
    default: false
  },
  ...breakpointProps,
  offset: {
    type: [String, Number],
    default: null
  },
  ...offsetProps,
  order: {
    type: [String, Number],
    default: null
  },
  ...orderProps,
  alignSelf: {
    type: String,
    default: null,
    validator: (str) => ["auto", "start", "end", "center", "baseline", "stretch"].includes(str)
  }
}, "col");
const Col = defineComponent({
  name: "VeCol",
  props: {
    ...makeTagProps(),
    ...makeColProps()
  },
  setup(props, {
    slots
  }) {
    const classes = computed(() => {
      const classList = [];
      let type;
      for (type in propMap) {
        propMap[type].forEach((prop) => {
          const value = props[prop];
          const className = breakpointClass(type, prop, value);
          if (className)
            classList.push(className);
        });
      }
      const hasColClasses = classList.some((className) => className.startsWith("ve-col-"));
      classList.push({
        "ve-col": !hasColClasses || !props.cols,
        [`ve-col-${props.cols}`]: props.cols,
        [`offset-${props.offset}`]: props.offset,
        [`order-${props.order}`]: props.order,
        [`align-self-${props.alignSelf}`]: props.alignSelf
      });
      return classList;
    });
    return () => createVNode(props.tag, {
      "class": classes.value
    }, _isSlot(slots) ? slots : {
      default: () => [slots]
    });
  }
});
export {
  Col,
  makeColProps
};
//# sourceMappingURL=col.mjs.map
