import { defineComponent, computed, onMounted, openBlock, createElementBlock, mergeProps, unref, createCommentVNode, createBlock, resolveDynamicComponent, renderSlot } from 'vue';
import '../../../utils/index.mjs';
import '../../../hooks/index.mjs';
import { iconProps } from './icon.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { isUndefined } from '../../../utils/types.mjs';
import { addUnit } from '../../../utils/dom/style.mjs';

const __default__ = defineComponent({
  name: "ElIcon",
  inheritAttrs: false
});
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: iconProps,
  setup(__props) {
    const props = __props;
    const icons = {};
    const ns = useNamespace("icon");
    const style = computed(() => {
      const { size, color } = props;
      if (!size && !color)
        return {};
      return {
        fontSize: isUndefined(size) ? void 0 : addUnit(size),
        "--color": color
      };
    });
    const camelcase = (str) => {
      const modifiedStr = str.replace(/-+$/, (match) => "_".repeat(match.length));
      const parts = modifiedStr.split(/-+/).filter((part) => part.length > 0);
      return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
    };
    const iconSvg = computed(() => {
      const { icon } = props;
      const key = camelcase(icon);
      return icons[key];
    });
    onMounted(() => {
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("i", mergeProps({
        class: unref(ns).b(),
        style: unref(style)
      }, _ctx.$attrs), [
        createCommentVNode(` <svg class="icon svg-icon" aria-hidden="true" v-if="icon && typeof icon == 'string'">
    </svg> `),
        _ctx.icon && typeof _ctx.icon == "string" ? (openBlock(), createBlock(resolveDynamicComponent(unref(iconSvg)), {
          key: 0,
          "aria-hidden": "true",
          class: "icon svg-icon"
        })) : renderSlot(_ctx.$slots, "default", { key: 1 })
      ], 16);
    };
  }
});
var Icon = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "icon.vue"]]);

export { Icon as default };
//# sourceMappingURL=icon2.mjs.map
